You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Michael Andrews <ma...@liveops.com> on 2009/01/09 01:01:15 UTC

Java map serialization

Hi,

I noticed on the wiki, the following java code snippet:

Work work = new Work();
TSerializer serializer = new TSerializer(new TSimpleJSONProtocol.Factory());
String json = serializer.toString(work);

where work is a struct defined in the IDL.

Is there a way to convert a List / Map so that it can be serialized in this manner?

Michael

Re: Java map serialization

Posted by David Reiss <dr...@facebook.com>.
No.  The code for serializing maps is generated and inlined into the
code that serializes the structure that contains it.  The Thrift
library has no support for serializing containers directly.

The loops are pretty simple, though, so you could copy them out of
the generated code, if you want.

--David

Michael Andrews wrote:
> Hi,
> 
> I noticed on the wiki, the following java code snippet:
> 
> Work work = new Work();
> TSerializer serializer = new TSerializer(new TSimpleJSONProtocol.Factory());
> String json = serializer.toString(work);
> 
> where work is a struct defined in the IDL.
> 
> Is there a way to convert a List / Map so that it can be serialized in this manner?
> 
> Michael