I would like to parse data from JSON which is of type String
.
I am using Google Gson.
I have:
jsonLine = \"
{
\"data\": {
\"translati
JsonParser parser = new JsonParser();
JsonObject jo = (JsonObject) parser.parse(data);
JsonElement je = jo.get("some_array");
//Parsing back the string as Array
JsonArray ja = (JsonArray) parser.parse(o.get("some_array").getAsString());
for (JsonElement jo : ja) {
JsonObject j = (JsonObject) jo;
// Your Code, Access json elements as j.get("some_element")
}
A simple example to parse a JSON like this
{ "some_array" : "[\"some_element\":1,\"some_more_element\":2]" , "some_other_element" : 3 }