在线 Json 验证器未验证 C# Json 格式[重复]
Posted
技术标签:
【中文标题】在线 Json 验证器未验证 C# Json 格式[重复]【英文标题】:C# Json formating is not validated by online Json validator [duplicate] 【发布时间】:2018-07-25 17:57:35 【问题描述】: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 字符串。请帮忙。
【问题讨论】:
【参考方案1】:看起来您在 .net 代码中将对象双重编码为 JSON。首先,您将一个对象编码为 JSON 并获取一个字符串。
console.log(
"normal encoded:",
JSON.stringify(hello:"world")
);
console.log(
"double encoded:",
JSON.stringify(JSON.stringify(hello:"world"))
);
问题可能不在 ES 中,而在您的 .net 代码中。您的问题的解决方案很可能是here。
【讨论】:
以上是关于在线 Json 验证器未验证 C# Json 格式[重复]的主要内容,如果未能解决你的问题,请参考以下文章