如何解析以下字符串
var a = JSON.parse('[' + '{"NoteName":"it's my life","UserId":"100","NoteActive":true,"UserEmail":"admin@dev.xrc.com","CreatedDate":"8/13/2012 1:47:35 PM"}' + ']');
答案 0 :(得分:7)
你只需要逃避单引号it\'s
var a = JSON.parse('[' + '{"NoteName":"it\'s my life","UserId":"100","NoteActive":true,"UserEmail":"admin@dev.xrc.com","CreatedDate":"8/13/2012 1:47:35 PM"}' + ']');
console.log(a);
答案 1 :(得分:2)
您可以使用反斜杠转义(仅作为字符解释)引号。 “\”“或'\''
答案 2 :(得分:2)
将it's
替换为it\'s
'[' + '{"NoteName":"it\'s my life","UserId":"100","NoteActive":true,"UserEmail":"admin@dev.xrc.com","CreatedDate":"8/13/2012 1:47:35 PM"}' + ']'