pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "aappddeevv" <aappdde...@verizon.net>
Subject RE: recommendation requested: json translation into objects
Date Sat, 03 Jul 2010 11:52:13 GMT
Google gson? I think that's a clever name. Gson looks like it smartly
attacks this problem. I love the fact it supports generics. Thanks for the

I think the small code snippet in an earlier response helps, the only
problem is that some objects don't serialize/deserialize very well (no fault
of pivot) and I want to have custom translation much like pivot does with
paint deserialization from a json string so that I have a simpler-than-xml
way to represent some objects and markup, specifically around affine
transformations for the SVG component I recently posted.

For my single object needs, I'll do it like pivot with a single converter,
although it would be nice if pivot had a ConverterService to be called by
any component to translate from json string to an object...pivot could load
its converters and other people could write theirs and contribute them with
a standard mechanism.  But is not an essential service to pivot today.

-----Original Message-----
From: Clint Gilbert [mailto:clint_gilbert@hms.harvard.edu] 
Sent: Friday, July 02, 2010 10:08 AM
To: user@pivot.apache.org
Subject: Re: recommendation requested: json translation into objects

Hash: SHA1

aappddeevv wrote:
> I have some properties on a skin that need to be translated from json
syntax to an object. Pivot seems to have a few translators for colors and
paints for its needs.
> However, I have some other structures to convert.
> What recommendation do people have for converting json syntax to an
object? Should I grab a library? If so, any suggestions on which one?

I've had good experiences with Google's Gson:


though I don't know if it would be suitable here.  It has some nice
features, like being able to turn [1,2,3,4,5] into a
java.util.List<Integer>.  It can also do things like turn
[{'x':1},{'x':2},{'x':3},{'x':4},{'x':5}] into a List<Foo>, if you have

class Foo {
    int x;

Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


View raw message