Javascript 在线Json验证程序不会验证C#Json格式
C#Webservice正在生成此jsonJavascript 在线Json验证程序不会验证C#Json格式,javascript,c#,json,angular,wcf,Javascript,C#,Json,Angular,Wcf,C#Webservice正在生成此json [{\"Question\":\"This is the Question no 0\",\"Answer1\":\"This is Answer1 of Question 0\",\"Answer2\":\"This is Answer2 of Question 0\",\"Answer3\":\"This is Answer3 of Question 0\",\"Answer4\":\"This is Answer4 of Question 0\"
[{\"Question\":\"This is the Question no 0\",\"Answer1\":\"This is Answer1 of Question 0\",\"Answer2\":\"This is Answer2 of Question 0\",\"Answer3\":\"This is Answer3 of Question 0\",\"Answer4\":\"This is Answer4 of Question 0\",\"Correct\":1},{\"Question\":\"This is the Question no 1\",\"Answer1\":\"This is Answer1 of Question 1\",\"Answer2\":\"This is Answer2 of Question 1\",\"Answer3\":\"This is Answer3 of Question 1\",\"Answer4\":\"This is Answer4 of Question 1\",\"Correct\":1},{\"Question\":\"This is the Question no 2\",\"Answer1\":\"This is Answer1 of Question 2\",\"Answer2\":\"This is Answer2 of Question 2\",\"Answer3\":\"This is Answer3 of Question 2\",\"Answer4\":\"This is Answer4 of Question 2\",\"Correct\":1}]
但是在线json验证器在json字符串中显示错误。Angular也没有正确解析json字符串并给出错误。我正在使用Newtonsoft json serialize生成json字符串。请提供帮助。看起来您在.net代码中将对象双重编码为JSON。首先,将一个对象编码为JSON并获得一个字符串
console.log(
“正常编码:”,
stringify({hello:“world”})
);
console.log(
“双重编码:”,
stringify(JSON.stringify({hello:“world”}))
);代码>