title: Access nested JSON data using jquery or javascript?
body: <p>I have a JSON data like a below format: </p>
  
  <pre><code>var jsonData = {
       "@type": "DimensionSearchService",
           "name": "Dimension Search Service",
           "dimensionSearchResults": {
           "@type": "DimensionSearchResults",
               "totalNumResults": 20,
               "dimensionSearchGroups": [{
               "@class": "com.endeca.infront.cartridge.model.DimensionSearchGroup",
                   "displayName": "CHEMICAL GROUP",
                   "dimensionSearchValues": [{
                   "@class": "com.endeca.infront.cartridge.model.DimensionSearchValue",
                       "multiSelect": true,
                       "navigationState": "?N=4294957096",
                       "contentPath": "\/guidedsearch",
                       "count": 1,
                       "siteRootPath": "\/services",
                       "ancestors": [],
                       "label": "acidic drugs",
                       "properties": {}
               }, {
                   "@class": "com.endeca.infront.cartridge.model.DimensionSearchValue",
                       "multiSelect": true,
                       "navigationState": "?N=4294958340",
                       "contentPath": "\/guidedsearch",
                       "count": 1,
                       "siteRootPath": "\/services",
                       "ancestors": [],
                       "label": "anti diabetic drugs",
                       "properties": {}
               }, {
                   "@class": "com.endeca.infront.cartridge.model.DimensionSearchValue",
                       "multiSelect": true,
                       "navigationState": "?N=4294957903",
                       "contentPath": "\/guidedsearch",
                       "count": 1,
                       "siteRootPath": "\/services",
                       "ancestors": [],
                       "label": "anti viral drugs",
                       "properties": {}
               }, {
                   "@class": "com.endeca.infront.cartridge.model.DimensionSearchValue",
                       "multiSelect": true,
                       "navigationState": "?N=4294958300",
                       "contentPath": "\/guidedsearch",
                       "count": 1,
                       "siteRootPath": "\/services",
                       "ancestors": [],
                       "label": "antiestrogen drugs",
                       "properties": {}
               }]
               }]
           }
   };
  </code></pre>
  
  <p>Actually I wanted to get the <strong>label</strong> value from this JSON data. However my script is giving me the following error. Any idea what is wrong ?</p>
  
  <pre><code>var parsed = JSON.parse(jsonData);
  for (var z = 0; z &lt; parsed.length; z++) {
      var response = parsed.dimensionSearchResults.dimensionSearchGroups[z].dimensionSearchValues[z].label;
      console.log(response);
  }
  </code></pre>
  
  <p><strong>Error</strong></p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'dimensionSearchValues' of undefined
  </code></pre>