[
{
"id":1,
"name":"Ashiz",
"email":"ashizhamal@gmail.com",
"message":"How are you yankee\r\n",
"created_at":"2017-05-24 03:16:53",
"updated_at":"2017-05-24 03:16:53"
}
]
.map(res => res.json());
虽然我以上述方式使用json数据,但它的工作正常。我可以使用json数据,但当我使用这种方式作为对象只有我得到错误。 为什么?方括号和无方括号之间有什么区别?如何使用它?
{
"id":1,
"name":"Ashiz",
"email":"ashizhamal@gmail.com",
"message":"How are you yankee\r\n",
"created_at":"2017-05-24 03:16:53",
"updated_at":"2017-05-24 03:16:53"
}
答案 0 :(得分:1)
如果您未使用[]
,则需要parse
$.parseJSON,如下所示。
jQuery.parseJSON({
"id":1,
"name":"Ashiz",
"email":"ashizhamal@gmail.com",
"message":"How are you yankee\r\n",
"created_at":"2017-05-24 03:16:53",
"updated_at":"2017-05-24 03:16:53"
});