How do I parse this JSON?
{
"result": [
{
"animals": [
{
"id": 1,
"name": "pig",
}
]
}
]
}
I have tried to parse the JSON by:
jsonobject := TJsonObject.ParseJSONValue(RestResponse.Content) as TJsonObject;
Then I get "animals":[{"id" ... . Now here it gets complicated, how do I parse further to get id and name? Parse JSON further or parse JSON array? Can someone help me (with example code), please?
Your JSON string contain an array embedded in another array. You can get the value of the first array ("result") and iterate its elements. For each element you have an array of "animals" that you can iterate to get "id" and "name".
Simple code to do that :