[英]json error Bad JSON escape sequence
I am working with json but i got an error Bad JSON escape sequence 我正在使用json,但我收到错误Bad JSON转义序列
var model = JsonConvert.DeserializeObject<test>(def);
public class test
{
public string test123 { get; set; }
}
My json def is "{\\"test123 \\": \\"î'ï\¹\ö\\\\±ýŽ± \Eú\\", }"
我的json def是"{\\"test123 \\": \\"î'ï\¹\ö\\\\±ýŽ± \Eú\\", }"
Please use 4 back slashes to print a single back slash in the resultant JSON string. 请使用4个反斜杠在结果JSON字符串中打印单个反斜杠。 Two slashes turns into one slash and escapes C#'s string only, to escape JSON, you will need another two. 两个斜杠变成一个斜线并且仅转义C#的字符串,为了逃避JSON,你将需要另外两个。 Or use can use the @ string for simplification. 或者使用可以使用@字符串进行简化。
"{\"test123 \": \"î'ï\u0014¹\u0019ö\\\\±ýŽ± \u0013Eú\", }"
Or 要么
@"{""test123 "": ""î'ï\u0014¹\u0019ö\\±ýŽ± \u0013Eú"", }"
首先,您可以使用jsonlint验证您的JSON。然后您可以使用json2csharp为您的JSON创建正确的类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.