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
Post a Comment