1. #1
    Sencha User
    Join Date
    Jun 2012
    Posts
    10
    Vote Rating
    0
    prmondal is on a distinguished road

      0  

    Default Unanswered: Parsing Nested Json

    Unanswered: Parsing Nested Json


    I am getting a response in nested JSON format from the server which is below:

    Code:
    {
       "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.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,404
    Answers
    3549
    Vote Rating
    849
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      1  

    Default


    Are you using associations?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Jun 2012
    Posts
    10
    Vote Rating
    0
    prmondal is on a distinguished road

      0  

    Default


    Can you give some examples for associations?

  4. #4
    Sencha User
    Join Date
    Jan 2014
    Posts
    13
    Answers
    1
    Vote Rating
    0
    cyb3rjithu is on a distinguished road

      0  

    Default


    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..

  5. #5
    Sencha User
    Join Date
    Jun 2012
    Posts
    10
    Vote Rating
    0
    prmondal is on a distinguished road

      0  

    Default


    @ cyb3rjithu
    I finally implemented it long back ago. It can be done using associations.
    http://docs.sencha.com/extjs/4.0.7/#...Ext.data.Model

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

  6. #6
    Sencha User
    Join Date
    Jan 2014
    Posts
    13
    Answers
    1
    Vote Rating
    0
    cyb3rjithu is on a distinguished road

      0  

    Default


    @prmondal : thank you for the reply.. do u have any sample codes with so that i can use them as a reference ?

Thread Participants: 2