我有一个JSON数组,该数组的键中带有方括号,例如““ {
{
"msg":"OK",
"data":[
{
"nls!type":"NCR",
"current":"Assign",
"physicalid":"0FFE0001000009FC5BD6805C00001352",
"attribute[custTitle]":"Title",
"name":"181002",
"description":""
}
]
}
我如何在javascript中获得"attribute[custTitle]"
的值
当我尝试获取arrData[i].attribute[custTitle]
时,由于未定义custTitle,它会返回错误,我可以通过相同的方式获取其他值。
答案 0 :(得分:1)
尝试
const response = {
"msg":"OK",
"data":[
{
"nls!type":"NCR",
"current":"Assign",
"physicalid":"0FFE0001000009FC5BD6805C00001352",
"attribute[custTitle]":"Title",
"name":"181002",
"description":""
}
]
};
console.log(response.data[0]['attribute[custTitle]']);