我想在ActionScript 2中獲取JSON對象的值,但它一直返回undefined或[object Object]。Flash ActionScript 2 JSON返回[對象對象]
這裏是我的代碼:
for (var i:Number = 0; i < oProduct.prosAndCons.pros.length; i++) {
if (i == oProduct.prosAndCons.pros.length) {
break;
};
//
mcProsCons.txtPros.htmlText += oProduct.prosAndCons.pros[i]+ "<br /><br />";
};
這裏是返回的JSON:
{
"prosAndCons": {
"pros": [
{
"cute animals": {
"link": "http://searchreviews.com/best/q-1661072-cute-animals",
"excerptCount": 1,
"excerpt": "Cute songs and cute animals."
}
},
{
"cute toy": {
"link": "http://searchreviews.com/best/q-3584162-cute-toy",
"excerptCount": 6,
"excerpt": "All in all it's a very cute toy that holds up to a lot of use."
}
},
{
"cute songs": {
"link": "http://searchreviews.com/best/q-1769522-cute-songs",
"excerptCount" :2,
"excerpt": "Cute songs and cute animals."
}
},
{
"chunky magnetic letters": {
"link": "http://searchreviews.com/best/q-662-chunky-magnetic-letters",
"excerptCount": 1,
"excerpt": "The chunky magnetic letters are perfect for little hands and the magnets that hold them to the fridge are enclosed so there is no worry of a swallow hazard."
}
},
{
"catchy song": {
"link": "http://searchreviews.com/best/q-672-catchy-song",
"excerptCount": 4,
"excerpt": "\" You made a match, look what you have done ,\" It's a very catchy song!"
}
}
]
}
}
誰能告訴我什麼,我做錯了什麼?這是一段時間,因爲我用AS2編碼W/JSON。
提示:'prosAndCons.pros [0]'是一個對象。 – Marty 2012-04-17 03:04:51
任何其他提示? – BrownFreelance 2012-04-17 04:45:42
看看我對你的JSON所作的編輯,看看你能否發現任何東西。 – Marty 2012-04-17 04:50:59