Oh yes. I'm using it that way now, that's what motivated a JIRA to add
putAll to the BeanAdapter J

 

From: Greg Brown [mailto:[email protected]] 
Sent: Saturday, July 03, 2010 8:06 AM
To: [email protected]
Subject: Re: recommendation requested: json translation into objects

 

FWIW, JSONSerializer can also easily convert JSON strings to lists or maps:

 

List<?> list = JSONSerializer.parseList("[1, 2, 3, 4, 5]");

Map<String, ?> map = JSONSerializer.parseMap("{a:1, b:2, c:3}");

 

It will also automatically deserialize the data into custom classes if you
pass the constructor an appropriate type.





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
reference.

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

http://code.google.com/p/google-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;
}

 

Reply via email to