Hi,
How do I parse the following JSON output from an API call. I have managed to loop through the highest level of the json with a foreach and can get objects with their “id” values. My problem is how to loop through the “Answers” level to read the “name” value. I have tried a nested foreach loop but just can’t make it work.
{
"responseCode": 200,
"message": "success",
"content": [
{
"id": "5177324193621660980",
"form_id": "220077009162952",
"ip": "62.92.26.3",
"created_at": "2022-01-11 12:47:00",
"updated_at": null,
"answers": {
"1": {
"name": "clickTo",
"order": "1",
"text": "Søknad om å opprette et Team",
"type": "control_head"
},
"2": {
"name": "submit",
"order": "10",
"text": "Send inn",
"type": "control_button"
},
"5": {
"name": "Begrunnelse",
"order": "5",
"text": "Hva er begrunnelsen for at du trenger et team? ",
"type": "control_textarea",
"answer": "Oppgradering av nettverk"
},
}
},
{
"id": "5177311423624123388",
"form_id": "220077009162952",
"ip": "62.92.26.3",
"created_at": "2022-01-11 12:25:43",
"updated_at": null,
"answers": {
"1": {
"name": "clickTo",
"order": "1",
"text": "Søknad om å opprette et Team",
"type": "control_head"
},
"2": {
"name": "submit",
"order": "10",
"text": "Send inn",
"type": "control_button"
},
"5": {
"name": "Begrunnelse",
"order": "5",
"text": "Hva er begrunnelsen for at du trenger et team? ",
"type": "control_textarea",
"answer": "Prosjekt sikkerhet 2022"
},
}
}
],
"duration": "14.37ms",
"resultSet": {
"offset": 0,
"limit": 20,
"count": 3
}
}
Please keep it simple. Thanks