I am having JSON string as follows
String jtext= {"data":{"key1":"hello","key2":{"key21": [{"key211":"val1","key212":"val2","key213":"val3},{......},{.....}……..]}}
I am only interested in array inside key21
. Is it possible to directly get the array inside key21
?
I have tried the code below and it's working fine
JsonElement elementKey = new JsonParser().parse(jtext);
JsonObject eleObject = elementKey.getAsJsonObject();
JsonObject dataobj = eleObject.getAsJsonObject("data");
JsonObject key2= elementKey.getAsJsonObject("key2");
JsonArray jarray = data1.getAsJsonArray("key21");
So is it possible to directly penetrate into the JSON object to get array inside key21
in Gson ? I don't want whole linking from parent to get into the desired element or may be solution to minimize the LOC.