我的编码返回json数组,对象有特殊字符,我无法在编码中检索数据。
示例:
{ "No." : "3",
"sign" : "positive",
"nr_old" : "",
"referring domain or url":"www.google.co.za",
"visits" : "1",
"avg. pv/ v" :"4.0",
"graph" : ""
}
在上面的示例中,我无法检索“否”和“引用域名或网址”和“平均pv / v”
答案 0 :(得分:1)
在这种情况下,您必须使用括号表示法来访问该属性:
var value = obj['No.']; // obj['referring domain or url'], etc.
答案 1 :(得分:1)
data = {
"No." : "3",
"sign" : "positive",
"nr_old" : "",
"referring domain or url":"www.google.co.za",
"visits" : "1",
"avg. pv/ v" :"4.0",
"graph" : ""
}
data['No.'] // '3'
data['avg. pv/ v'] // '4.0'
data['referring domain or url'] // 'www.google.co.za'