-5
嗨我想解析简单的JSON(字符串),但我得到错误。 这是目标,我需要得到JOSN.parse函数无法正常工作
{
"heading" : "The movies",
"box5" : "Click on icon to add text.",
"box1" : "At the movies,you can watch for an hour. ",
"box2" : "You can go eat popcorn,candy,and soda. ",
"box7" : "At the movies you will want to go again. ",
"box3" : "At the movies ,you can play games.",
"box4" : "you can go and have fun with your friends and family.And get to spent time with them.======== ",
"box6" : "Click on icon to add text."
};
。========
我觉得这是有规律的字符串中的字符
当我删除=== =====我造成
var st = '{"heading": "The movies","box5": "Click on icon to add text.","box1": "At the movies,you can watch for an hour. ","box2": "You can go eat popcorn,candy,and soda. ","box7": "At the movies you will want to go again. ","box3": "At the movies ,you can play games.","box4": "you can go and have fun with your friends and family.And get to spent time with them.","box6": "Click on icon to add text."}';
console.log(st);
var res = JSON.parse(st);
console.log('res: ' + res.heading);
包括
var st = '{"heading": "The movies","box5": "Click on icon to add text.","box1": "At the movies,you can watch for an hour. ","box2": "You can go eat popcorn,candy,and soda. ","box7": "At the movies you will want to go again. ","box3": "At the movies ,you can play games.","box4": "you can go and have fun with your friends and family.And get to spent time with them.======== \t ","box6": "Click on icon to add text."}';
console.log(st);
var res = JSON.parse(st);
console.log('res' + res.heading);
我没有收到任何错误。 – Xufox
请在一个代码块中显示您的JSON(**,只是**您的JSON),并在另一个代码块中显示您的代码。现在有什么是一种混杂的混搭,包括看起来像你的JSON(这将是无效的),所以它很难帮助你。 –
如果我们假设你的JSON是'{'到'}'的一部分而不包括';',那么JSON就没问题。 –