我有问题。我在一个单独的文件中有 JSON 对象的列表,但想将它们解析为数据表。每次我尝试解析它们时,都会出现意外的字符错误......
这是代码
var myJSONObject = {
"orders" : [{
"orderId" : "K2_001",
"dueDate" : "04/15/2012",
"priority" : 1,
"description" : "ORDER K2_001"
}, {
"orderId" : "K2_002",
"dueDate" : "04/20/2012",
"priority" : 2,
"description" : "ORDER K2_002"
}, {
"orderId" : "K2_003",
"dueDate" : "04/23/2012",
"priority" : 3,
"description" : "ORDER K2_003"
}, {
"orderId" : "K2_004",
"dueDate" : "04/27/2012",
"priority" : 4,
"description" : "ORDER K2_004"
}, {
"orderId" : "K2_005",
"dueDate" : "04/30/2012",
"priority" : 5,
"description" : "ORDER K2_005"
}, {
"orderId" : "K2_006",
"dueDate" : "05/05/2012",
"priority" : 6,
"description" : "ORDER K2_006"
}, {
"orderId" : "K2_007",
"dueDate" : "05/12/2012",
"priority" : 7,
"description" : "ORDER K2_007"
}, {
"orderId" : "K2_008",
"dueDate" : "05/14/2012",
"priority" : 8,
"description" : "ORDER K2_008"
}]
};
var jsonObject2 = Y.JSON.parse(myJSONObject.responseText);