我有这个我试图访问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之前没有注意到您的答案。 –