以下の形式の JSON データがあります。「Non Veg」で specialDeal が true になっている店舗に対応する店舗名を取得する必要があります。(注: ストアの 1 つだけが specialDeal を true に設定します。また、nonVeg 内のコンテンツは配列ではないことに注意してください)。どうすれば取得できますか? 助けてください。前もって感謝します。
{
"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":""
}
私が試したコードは次のとおりです。
var nonveg = DealsJSON.Non Veg; //where JSON is our json data
for (var key in nonveg) {
for (var i = 0; i < nonveg[key].length; i++) {
var amountObj = nonveg[key][i];
if (amountObj['specialDeal'] == true) {
console.log(amountObj['Store']);
}
}
}