PDA

View Full Version : Parsing Nested Json



prmondal
22 Nov 2012, 1:22 AM
I am getting a response in nested JSON format from the server which is below:


{
"Feedback":[
{

"Question":"question1",
"Answers":[
{
"Answer":"answer1",
"AId":1
},
{
"Answer":"answer2",
"AId":2
}
],
"QuestionId":1
},
{
"Question":"question2",
"Answers":[
{
"Answer":"answer3",
"AId":3
},
{
"Answer":"answer4",
"AId":4
},
{
"Answer":"answer5",
"AId":5
}
],
"QuestionId":2
}
]
}

The above JSON is dynamic which means the number of answers for each question may vary.
How can I parse this JSON and display answers in a combo box correspond to each question?

Please help.

mitchellsimoens
24 Nov 2012, 6:23 AM
Are you using associations?

prmondal
26 Nov 2012, 2:08 AM
Can you give some examples for associations?

cyb3rjithu
18 Jan 2014, 4:53 AM
I'm Also having the same problem and I didn't use any associations here... How can i parse such kind of JSON data??
Thanking you in advance..

prmondal
18 Jan 2014, 8:10 AM
@ cyb3rjithu
I finally implemented it long back ago. It can be done using associations.
http://docs.sencha.com/extjs/4.0.7/#!/api/Ext.data.Model

Read the documentation for associations. I implemented easily after reading this. Hope this helps.

cyb3rjithu
23 Jan 2014, 9:52 PM
@prmondal : thank you for the reply.. do u have any sample codes with so that i can use them as a reference ?