Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在线Json验证程序不会验证C#Json格式_Javascript_C#_Json_Angular_Wcf - Fatal编程技术网

Javascript 在线Json验证程序不会验证C#Json格式

Javascript 在线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\"

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 serialize生成json字符串。请提供帮助。

看起来您在.net代码中将对象双重编码为JSON。首先,将一个对象编码为JSON并获得一个字符串

console.log(
“正常编码:”,
stringify({hello:“world”})
);
console.log(
“双重编码:”,
stringify(JSON.stringify({hello:“world”}))
);