'How To Get Json object inside json object

My code snippet for nested json object:

JsonArray arr = jsonObject.getAsJsonArray("data");
for(int i = 0; i < arr.size(); i++) {
    String _Id =  arr.get(i).getAsJsonObject().get("_id").getAsString();
    String Name = arr.get(i).getAsJsonObject().get("name").getAsString();
    int Trips = arr.get(i).getAsJsonObject().get("trips").getAsInt();
}


Solution 1:[1]

You can parse JSON using JSON.parse();

let exampleJSON = '{ "id": 245, "name": "Mike" }';

const obj = JSON.parse(exampleJSON);

console.log(obj.id); // 245

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Auracle