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\",\"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序列化来生成json字符串。请帮忙。
答案 0 :(得分:0)
看起来你在.net代码中将对象双重编码为JSON。首先,将对象编码为JSON并获取字符串。
console.log(
"normal encoded:",
JSON.stringify({hello:"world"})
);
console.log(
"double encoded:",
JSON.stringify(JSON.stringify({hello:"world"}))
);

问题可能不在ES中,而在您的.net代码中。问题的解决方案可能是here。