java - Parse JSON to array of objects -


currently i'm receiving following json data in action:

[     { "civilstatus": "m" },     "and",     { "familysize": "2|bw|4" },     "or",     { "civilstatus": "d" } ] 

i've been trying use play.libs.json parse string receive @ server, can't find way obtain array nor objects.

i have looked @ org.codehaus.jackson.jsonnode documentation, didn't figure way. i'm using java, not scala.

i have found using gson easier. add dependency in build.scala file:

val appdependencies = seq(     ... other dpenedencies ...     "com.google.code.gson" % "gson" % "2.1",     ... other dpenedencies ... ) 

then parse like:

gson gson = new gson(); list<yourcustombean> data = gson.fromjson(jsonstring, new typetoken<list<yourcustombean>>(){}.gettype()); 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -