Hi, I am trying to extract the values corresponding to all ‘QuestionId’ and ‘QuestionText’ from the below JSON response . The issue that I’m facing is that they are in multiple levels of the nested loop. Also, the below JSON nesting may vary every time and go till unknown iterations. Can someone please guide me how to do this?
P.S. I tried de-serialize JSON but I’m unable to figure things out post the first ‘QuestionId’ and ‘Questiontext’.
{“getQuestionsResponse”: {“decisionTree”: {
“Name”: “Siblings”,
“Status”: “NOT_DEFINED”,
“Question”: {
“QuestionId”: “565582”,
“QuestionText”: “Brother’s age”,
“QuestionType”: “NUMERIC”,
“branches”: {“branch”: [
{
“branchValue”: “0”,
“branchText”: “0”,
“Question”: {
“QuestionId”: “565583”,
“QuestionText”: “Sister’s age”,
“QuestionType”: “NUMERIC”,
“branches”: {“branch”: [
{
“branchValue”: “0”,
“branchText”: “0”,
“selected”: “0”
},
{
“branchValue”: “20”,
“branchText”: “20”,
“selected”: “0”
}
]}
},
“selected”: “0”
},
{
“branchValue”: “1”,
“branchText”: “1”,
“Question”: {
“QuestionId”: “565586”,
“QuestionText”: “Sister’s age”,
“QuestionType”: “NUMERIC”,
“branches”: {“branch”: [
{
“branchValue”: “0”,
“branchText”: “0”,
“selected”: “0”
},
{
“branchValue”: “20”,
“branchText”: “20”,
“selected”: “0”
}
]}
},
“selected”: “0”
},
{
“branchValue”: “20”,
“branchText”: “20”,
“Question”: {
“QuestionId”: “565589”,
“QuestionText”: “Sister’s age”,
“QuestionType”: “NUMERIC”,
“branches”: {“branch”: [
{
“branchValue”: “0”,
“branchText”: “0”,
“selected”: “0”
},
{
“branchValue”: “20”,
“branchText”: “20”,
“selected”: “0”
}
]}
},
“selected”: “0”
},
{
“branchValue”: “30”,
“branchText”: “30”,
“Question”: {
“QuestionId”: “565592”,
“QuestionText”: “Sister’s age”,
“QuestionType”: “NUMERIC”,
“branches”: {“branch”: [
{
“branchValue”: “0”,
“branchText”: “0”,
“selected”: “0”
},
{
“branchValue”: “20”,
“branchText”: “20”,
“selected”: “0”
},
{
“branchValue”: “30”,
“branchText”: “30”,
“selected”: “0”
}
]}
},
“selected”: “0”
}
]}
}
}}}
Any help is highly appreciated