无法将json字符串解析为JavaScript Object

时间:2016-09-02 09:40:11

标签: javascript json

我需要将json字符串(json对象)解析为js对象,但我失败了。

JSON:

result = {"user":{"name":"laoqiren","email":"7806494@qq.com","i mage":"https://sfault-avatar.b0.upaiyun.com/888/223/8882 23038-5646dbc28d530_huge256"},"totalTime":1.5,"date":"20 16-09-23","comment":"fffff"}

错误:

Unexpected end of input

为什么?

1 个答案:

答案 0 :(得分:0)

以下代码对我有用

var result = '{"user":{"name":"laoqiren","email":"7806494@qq.com","i mage":"https://sfault-avatar.b0.upaiyun.com/888/223/8882 23038-5646dbc28d530_huge256"},"totalTime":1.5,"date":"20 16-09-23","comment":"fffff"}';

var obj = JSON.parse(result);
console.log(obj);