Closed GoogleCodeExporter closed 9 years ago
I got the same cases.can you help me ?thank you in advance!
Original comment by huxiangy...@gmail.com
on 10 Apr 2013 at 5:19
This is not an error with json-io. The JSON you have listed is not any Java
object, because their is no '@type' tag in the JSON. Try creating a Bank
object and then writing one out like this:
Bank bank = new Bank();
String json = JsonWriter.toJson(bank);
System.out.println("bank in Json format");
System.out.println(json);
In order to be abe to cast it directly to an Java class, the JSON must include
the '@type' tag, or the Json must be an array '[]' in which is can be cast to a
Object[].
You can read this JSON String into memory like this:
String jsonString = "{\"name\": \"mybank\",\"address\": \"mybank address\"}";
Map map = JsonReader.jsonToMaps(jsonString);
This this code, you will be able to read in ANY JSON String and then access any
field of it, by drilling through the Maps.
Original comment by jdereg@gmail.com
on 1 Jun 2013 at 8:47
Original issue reported on code.google.com by
haris2...@gmail.com
on 5 Jul 2012 at 2:49