thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Pepersack <>
Subject Re: Encoding json
Date Sat, 05 Feb 2011 14:13:03 GMT
In Perl, it's trivial.  The JSON module from CPAN will round-trip any 
arbitrary structure of any depth into a JSON string in a very efficient 
manner.  See

use JSON;
$encoder = JSON->new();
$json_string = JSON->encode( $complex_structure );
$new_struct = JSON->decode( $json_string );

For Java, it appears that JSONStringer provides similar functionality 
although it's limited to 20 levels.  I haven't personally used it, 
however.  See:

You can embed Perl inside a Java program using PLJava -
You can embed Java inside a Perl program using Inline::Java -

On 02/04/2011 06:21 PM, Richard Salz wrote:
> So, how would you encode json, assuming no limits on nesting depth?
> Right now I'm thinking of "flattening" the structure, where you get the
> full name as list<string>, and the value as a string, which is either a
> simple value or empty, and you look for children to get the value of the
> aggregate.
> Any thoughts?
>          /r$
> --
> STSM, WebSphere Appliance Architect

View raw message