我试图在JavaScript中使用php数组,因此我使用以下代码对其进行了编码:
<?php
$json = json_encode($tracks, JSON_FORCE_OBJECT);
?>
结果是一个看起来像这样的对象,我正在尝试弄清楚如何用JavaScript解析它。
{
"0": {
“field_1”: “5464”,
"name": "Wed",
"ordinal": "0",
"created": "2016-04-05 17:30:20",
},
"1": {
“field_1”: “5464”,
"name": "Wed",
"ordinal": "0",
"created": "2016-04-05 17:30:20",
},
"2": {
“field_1”: “5464”,
"name": "Wed",
"ordinal": "0",
"created": "2016-04-05 17:30:20",
}
}
我尝试使用jQuery.parseJSON()函数,但是它不能正确处理数据。