我有這個我試圖訪問json值,但它甚至不產生任何警報。問題是什麼?訪問JSON字符串值
我的JSON
{
"response": [
{
"id": "0",
"elementName": "osname",
"isEqual": true,
"isPrasentinXml1": true,
"isPrasentinXml2": true,
"attribute": [
{
"name": "osname",
"firstValue": "Linux\u000a",
"secondValue": "SunOs\u000a"
}
]
},
{
"id": "1",
"elementName": "hostname",
"isEqual": false,
"isPrasentinXml1": true,
"isPrasentinXml2": true,
"attribute": [
{
"name": "hostname",
"firstValue": "estilo\u000a",
"secondValue": "buckeye.informatica.com\u000a"
}
]
}
]
}
我想獲取Linux\u000a
和SunOs\u000a
,所以我寫了
alert(compareData.response[0].attribute[0].firstValue+", "+compareData.response[0].attribute[0].secondValue);
注:compareData
是我的數據是實際的代碼
+1之前沒有注意到您的答案。 –