What is the difference between Serialization and Marshaling?

Marshaling and serialization are loosely synonymous in the context of remote procedure call, but semantically different as a matter of intent. In particular, marshaling is about getting parameters from here to there, while serialization is about copying structured data to or from a primitive form such as a byte stream. In this sense, serialization is … Read more

Json Java serialization that works with GWT [closed]

Take a look at GWT’s Overlay Types. I think this is by far the easiest way to work with JSON in GWT. Here’s a modified code example from the linked article: public class Customer extends JavaScriptObject { public final native String getFirstName() /*-{ return this.first_name; }-*/; public final native void setFirstName(String value) /*-{ this.first_name = … Read more

Passing a vector/array from unmanaged C++ to C#

As long as the managed code does not resize the vector, you can access the buffer and pass it as a pointer with vector.data() (for C++0x) or &vector[0]. This results in a zero-copy system. Example C++ API: #define EXPORT extern “C” __declspec(dllexport) typedef intptr_t ItemListHandle; EXPORT bool GenerateItems(ItemListHandle* hItems, double** itemsFound, int* itemCount) { auto … Read more

Marshal “char *” in C#

OregonGhost’s answer is only correct if the char* returned from GetDir is either allocated in HGlobal or LocalAlloc. I can’t remember which one but the CLR will assume that any string return type from a PInvoke function was allocated with one or the other. A more robust way is to type the return of GetDir … Read more

JAXB creating context and marshallers cost

Note: I’m the EclipseLink JAXB (MOXy) lead and a member of the JAXB 2 (JSR-222) expert group. JAXBContext is thread safe and should only be created once and reused to avoid the cost of initializing the metadata multiple times. Marshaller and Unmarshaller are not thread safe, but are lightweight to create and could be created … Read more

Why are date/time values interpreted incorrectly when patching/saving?

Date/time values are being casted/parsed in a locale aware fashion Update: this is the default behavior with the CakePHP application template versions prior to 3.2.5. As of 3.2.5 locale parsing is not enabled by default anymore, which will make the date/time marshalling logic expect a default format of Y-m-d H:i:s instead. In the marshalling process, … Read more

How do you specify the date format used when JAXB marshals xsd:dateTime?

You can use an XmlAdapter to customize how a date type is written to XML. package com.example; import java.text.SimpleDateFormat; import java.util.Date; import javax.xml.bind.annotation.adapters.XmlAdapter; public class DateAdapter extends XmlAdapter<String, Date> { private final SimpleDateFormat dateFormat = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”); @Override public String marshal(Date v) throws Exception { synchronized (dateFormat) { return dateFormat.format(v); } } @Override public … Read more