JSON下面没有得到验证。我无法找到问题
vartablearray=[
{
name: “Apple”,
code: “APPL”,
value: “111”,
bid: “112”,
offer: “110”
},
{
name: “Microsoft”,
code: “MSFT”,
value: “78”,
bid: “70”,
offer: “75”
},
{
name: “Google”,
code: “GOGL”,
value: “101”,
bid: “98”,
offer: “102”
},
{
name: “Nokia”,
code: “NOK”,
value: “10”,
bid: “8”,
offer: “9”
},
{
name: “Samsung”,
code: “SAMS”,
value: “89”,
bid: “86”,
offer: “90”
},
{
name: “IntelCorporation”,
code: “INTC”,
value: “111”,
bid: “112”,
offer: “110”
}
]
答案 0 :(得分:3)
JSON要求使用双引号键:
[{ "name": "Apple", ... }]
var tablearray=[ { name: “Apple” } ]
也会导致Javascript语法错误,因为javascript不理解您使用的“花哨”双引号,只有ASCII集中的“普通”双引号:var tablearray=[ { name: "Apple" } ]
或var tablearray=[ { "name": "Apple" } ]
答案 1 :(得分:1)
试试这个
var tablearray= jQuery.parseJSON('[ { "name": "Apple", "code": "APPL", "value": "111", "bid": "112", "offer": "110" }, { "name": "Microsoft", "code": "MSFT", "value": "78", "bid": "70", "offer": "75" }, { "name": "Google", "code": "GOGL", "value": "101", "bid": "98", "offer": "102" }, { "name": "Nokia", "code": "NOK", "value": "10", "bid": "8", "offer": "9" }, { "name": "Samsung", "code": "SAMS", "value": "89", "bid": "86", "offer": "90" }, { "name": "IntelCorporation", "code": "INTC", "value": "111", "bid": "112", "offer": "110" } ]');