thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Gill <gillt...@gmail.com>
Subject Re: Modelling JSON?
Date Wed, 29 Dec 2010 16:50:20 GMT
Hi Richard,

You've probably considered this but is there a reason you can't just
have the thrift IDL specify a string, and put JSON text into that
string before it goes through thrift, and parse the JSON string in
your app on the other end when it comes out?  Then you don't have to
worry about modifying thrift at all.

I've used this technique before and it worked really well - my data
structures kept changing but I didn't have to touch the IDL or
regenerate the code.  There were some snags with serializing dates (my
JSON parser wasn't smart enough to turn them into date objects
automatically on the other end) so I had to work around that but
otherwise it works great.

chris


On Wed, Dec 29, 2010 at 9:43 AM, Richard Salz <rsalz@us.ibm.com> wrote:
>> Do you mean like a truly arbitrary-depth recursive structure? Thrift
> can't
>> currently do this.
>
> Yes, that's exactly what I meant -- thanks for understanding so quickly!
> I'm not surprised by the answer.  I'm thinking what I should do.  I don't
> need arbitrary-depth (only 2 or 3), so I think I have a couple of options.
>  One is to write out the data structures to the depth I need. The other is
> to hook into thrift's serialization and recursively invoke it by hand --
> e.g., upper-levels just get the 'byte' type, which I then de/seraliaze by
> calling thrift functions directly. Any recommendations?
>
> Being able to specify my own serializer could be useful.  Is there an
> annotation for that?  I didn't find any docs on annotations other than
> samples in test/AnnotationTest.thrift, and some of them look interesting.
> :)
>
> Union implementation in C++ could also help.  Any thoughts on how to
> proceed (beyond, send a patch:)?
>
> Thanks.
>
>        /r$
>
> --
> STSM, WebSphere Appliance Architect
> https://www.ibm.com/developerworks/mydeveloperworks/blogs/soma/
>
>

Mime
View raw message