如何仅显示来自 JSON 的特殊信息?例如在 test.json 我们有
{
"productName": "Sencha Touch",
"version": "2.0 Beta",
"sampleData": [
{
"foo": "bar",
"desc": "This sample content is loaded from the server."
}
]
}
那么如何在按钮上单击 XMLHTTP。只显示来自“desc”的信息?
更新
如果我有这种如果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=?"
}
]
谢谢!