0
Example with JSON顯示來自JSON的選定信息
如何顯示來自JSON的特殊信息?例如在test.json中我們有
{
"productName": "Sencha Touch",
"version": "2.0 Beta",
"sampleData": [
{
"foo": "bar",
"desc": "This sample content is loaded from the server."
}
]
}
所以如何在按鈕上點擊XMLHTTP。只顯示來自「desc」的信息?
UPDATE
,如果我有這樣那樣,如果JSON解析如何呢?
[
{
"id": 7,
"answers": [
{
"id": 6,
"answer": "1",
"isCorrect": false
},
{
"id": 7,
"answer": "5",
"isCorrect": false
},
{
"id": 5,
"answer": "3",
"isCorrect": true
}
],
"question": "1+2=?"
},
{
"id": 14,
"answers": [
{
"id": 28,
"answer": "5",
"isCorrect": false
},
{
"id": 31,
"answer": "7",
"isCorrect": true
},
{
"id": 29,
"answer": "2",
"isCorrect": false
},
{
"id": 30,
"answer": "6",
"isCorrect": false
}
],
"question": "2+5=?"
},
{
"id": 9,
"answers": [
{
"id": 13,
"answer": "3",
"isCorrect": false
},
{
"id": 11,
"answer": "5",
"isCorrect": false
},
{
"id": 14,
"answer": "6",
"isCorrect": true
},
{
"id": 12,
"answer": "7",
"isCorrect": false
}
],
"question": "3+3=?"
}
]
Thx!
是的,謝謝。但有一點問題。如果我沒有其他JSON,請參閱更新。有什麼想法? – user2483213
與其他任何javascript對象一樣... – kevhender
我嘗試'contentView.setHtml(Ext.decode(response.responseText).question [0]);',但得到了錯誤 – user2483213