且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

JSON.parse意外的字符错误

更新时间:2022-05-18 21:58:04

你没有解析一个字符串,你正在解析一个已经解析过的对象:)

You're not parsing a string, you're parsing an already-parsed object :)

var obj1 = JSON.parse('{"creditBalance":0,...,"starStatus":false}');
//                    ^                                          ^
//                    if you want to parse, the input should be a string 

var obj2 = {"creditBalance":0,...,"starStatus":false};
// or just use it directly.