var products = [{
"name": "Pizza",
"price": "10",
"quantity": "7"
}, {
"name": "Cerveja",
"price": "12",
"quantity": "5"
}, {
"name": "Hamburguer",
"price": "10",
"quantity": "2"
}, {
"name": "Fraldas",
"price": "6",
"quantity": "2"
}];
console.log(products);
var b = JSON.parse(products); //unexpected token o
打开控制台查看错误信息
$('#mydata').data('person');
,那么JQuery会自动将数据字符串转换为JSON对象。这里不需要使用JSON.parse()
。 - Avatar$('#mydata').data('person');
,那么JQuery会自动将数据字符串转换为JSON对象。这里不需要使用JSON.parse()
。 - undefined