Javascript: How to retrieve a value from a JSON array having multiple nodes and arrays based on condition?
<p>I have JSON data that is in the format below. I need to get the store name corresponding to the one which has specialDeal as true in "Non Veg". (NOTE: Only one of the stores will have specialDeal as true and also please note the content inside nonVeg is not an array). How will I retrieve it? Please help. Thanks in advance.</p>

<pre><code>{
  "Veg": {
    "amtSpent":"", "shortDesc":"", "longDesc":"", "excTxt":"",
    "discntType":"", "Store":"", "StoreType":"", "Fund":"",
    "FundDetails":[
      {"status":"", "discntVal":"", "FundVal":"", "FundBal":""},
      {"status":"", "discntVal":"", "FundVal":"", "FundBal":""}
    ]
  },
  "Non Veg": {
    "chicken":[
      {
        "amtSpent":"", "shortDesc":"", "longDesc":"", "excTxt":"",
        "discntType":"", "Store":"", "StoreType":"", "Fund":"",
        "specialDeal":"", "promoStatus":"",
        "FundDetails":[
          {"status":"", "discntVal":"", "FundVal":"", "FundBal":""},
          {"status":"", "discntVal":"", "FundVal":"", "FundBal":""}
        ]
      },
      {
        "amtSpent":"", "shortDesc":"", "longDesc":"", "excTxt":"",
        "discntType":"", "Store":"", "StoreType":"", "Fund":"",
        "specialDeal":"", "promoStatus":"",
        "FundDetails":[
          {"status":"", "discntVal":"", "FundVal":"", "FundBal":""},
          {"status":"", "discntVal":"", "FundVal":"", "FundBal":""}
        ]
      }
    ],
    "fish":[
      {
        "amtSpent":"", "shortDesc":"", "longDesc":"", "excTxt":"",
        "discntType":"", "Store":"", "StoreType":"", "Fund":"",
        "specialDeal":"", "promoStatus":"",
        "FundDetails":[
          {"status":"", "discntVal":"", "FundVal":"", "FundBal":""},
          {"status":"", "discntVal":"", "FundVal":"", "FundBal":""}
        ]
      },
      {
        "amtSpent":"", "shortDesc":"", "longDesc":"", "excTxt":"",
        "discntType":"", "Store":"", "StoreType":"", "Fund":"",
        "specialDeal":"", "promoStatus":"",
        "FundDetails":[
          {"status":"", "discntVal":"", "FundVal":"", "FundBal":""},
          {"status":"", "discntVal":"", "FundVal":"", "FundBal":""}
        ]
      }
    ],
    "egg":[
      {
        "amtSpent":"", "shortDesc":"", "longDesc":"", "excTxt":"",
        "discntType":"", "Store":"", "StoreType":"", "Fund":"",
        "specialDeal":"", "promoStatus":"",
        "discntVal":"", "FundVal":"", "FundBal":""
      },
      {
        "amtSpent":"", "shortDesc":"", "longDesc":"", "excTxt":"",
        "discntType":"", "Store":"", "StoreType":"", "Fund":"",
        "specialDeal":"", "promoStatus":"",
        "discntVal":"", "FundVal":"", "FundBal":""
      }
    ]
  },
  "isMember":"Y",
  "orderId":""
}
</code></pre>

<p>Here's the code I've tried:</p>

<pre><code>var nonveg = DealsJSON.Non Veg; //where JSON is our json data
for (var key in nonveg) {
    for (var i = 0; i &lt; nonveg[key].length; i++) {
        var amountObj = nonveg[key][i];
        if (amountObj['specialDeal'] == true) {
            console.log(amountObj['Store']);
        }
    }
}
</code></pre>
