title: How to parse nested array json response value in sencha
body: <p>I am trying to parse a childId value in below Response. I am unable to parse the value. I am a newbie to the association and hasMany concepts. I am giving an alert childId value in app.js but it's not displaying. Can anybody tell me whether my mapping is correct? Can anybody tell me what the problem is and how to fix it?</p>
  
  <p><strong>Sample.Json</strong></p>
  
  <pre><code>{
          "parents":{
           "parent1":{
             "parent":[
               {
                   "children":{
                       "child":[
                        {
                            "childId":1,
                            "childdetails": {
                    "childrendetails": [
                      {
                        "childName": "Test",
                        "childAge": "19"
                      },
                      {
                        "childName": "Test1",
                        "childAge": "20"
                      }
                    ]
                  }
  
                    },
                        {
                            "childId":2,
                             "childdetails": {
                    "childrendetails": [
                      {
                        "childName": "Test2",
                        "childAge": "25"
                      },
                      {
                        "childName": "Test3",
                        "childAge": "24"
                      }
                    ]
                  } 
  
  
                        }
                     ]
                  }
               },
               {
              "children":{
                     "child":[
                        {
                           "childId":3,
                           "childdetails": {
                    "childrendetails": [
                      {
                        "childName": "Test4",
                        "childAge": "25"
                      },
                      {
                        "childName": "test5",
                        "childAge": "21"
                      }
                    ]
                  }
  
  
                        },
                        {
                           "childId":4,
                            "childdetails": {
                    "childrendetails": [
                      {
                        "childName": "Test6",
                        "childAge": "26"
                      },
                      {
                        "childName": "test7",
                        "childAge": "27"
                      }
                    ]
                  }
                       }
  
  
  
  
                     ]
                  },
  
  
                 "parentName":"firstName",
                 "parentAge":"28"
  
               },
  
  
               {
                   "children":{
                       "child":[
                        {
                            "childId":5,
                            "childdetails": {
                    "childrendetails": [
                      {
                        "childName": "Test8",
                        "childAge": "24"
                      },
                      {
                        "childName": "Test9",
                        "childAges": "27"
                      }
                    ]
                  }
  
  
                        },
                        {
                            "childId":6,
                             "childdetails": {
                    "childrendetails": [
                      {
                        "childName": "Test10",
                        "childAge": "25"
                      },
                      {
                        "childName": "Test11",
                        "childAge": "24"
                      }
                    ]
                  } 
  
  
                        }
                     ]
                  }
               },
               {
                  "children":{
                     "child":[
                        {
                           "childId":7,
                           "childdetails": {
                    "childrendetails": [
                      {
                        "childName": "Test12",
                        "childAge": "25"
                      },
                      {
                        "childName": "Test13",
                        "childAge": "21"
                      }
                    ]
                  }
  
  
                        },
                        {
                           "childId":8,
                            "childdetails": {
                    "childrendetails": [
                      {
                        "childName": "Test14",
                        "childAge": "26"
                      },
                      {
                        "childName": "Test15",
                        "childAge": "27"
                      }
                    ]
                  }
                       }
  
  
                  ]
                  },
  
  
                 "parentName":"secondname",
                 "parentAge":"35"
  
               }
  
              ]
  
         }
  
  
      }
  
      }
  </code></pre>
  
  <p><strong>ParentModel.js</strong></p>
  
  <pre><code>Ext.define("extcityview.model.ParentModel", {
      extend: 'Ext.data.Model',
       fields: [
          'parentName', 'parentAge'
      ],
      hasMany: {model: 'extcityview.model.ChildrenModel', name: 'children'},
  
  });
  
  
  
  
  Ext.define("extcityview.model.ChildrenModel", {
      extend: 'Ext.data.Model',
      hasMany  : {model:'extcityview.model.ChildModel', name:'child', associationKey: 'childItems'},
      belongsTo: 'extcityview.model.ParentModel'
  });
  
  
  Ext.define("extcityview.model.ChildModel", {
      extend: 'Ext.data.Model',
      fields: [
           'childId'
      ],
       belongsTo: 'extcityview.model.ChildrenModel'
  });
  </code></pre>
  
  <p>ChildStore.js</p>
  
  <pre><code>Ext.define('extcityview.store.ChildStore', {
      extend : 'Ext.data.Store',
      storeId : 'samplestore',
      model : 'extcityview.model.ParentModel',
      autoLoad : 'true',
      proxy : {
          type : 'ajax',
          url : 'sample.json',
          reader : {
              type  : 'json',
              root  :'parents.parent1.parent'     
          }
      }
  
  }); 
  </code></pre>
  
  <p>app.js</p>
  
  <pre><code>var store = Ext.create('extcityview.store.ChildStore', {
  
                                 model: "extcityview.model.ParentModel",
  
  });
  
  store.load({
              callback: function() 
              {
                console.log("i am in callback");
                  var parent = store.first();
                  alert("parent"+parent);
                  console.log("parent"+parent);
                  parent.children().each(function(children){
                   children.child().each(function(child)  {
                   alert("sub region anme"+child.get('childId'));
                   console.log("sub region name"+child.get('childId'));
  
                   });
  
  
  
  
                  }); 
              }
          });
  </code></pre>
  
  <p>Thanks</p>