简体   繁体   English

Newtosoft.Json Bad JSON转义序列:\\ v。

[英]Newtosoft.Json Bad JSON escape sequence: \v.

I am using Newtosoft.Json for parsing JSON, which is quite normal in C# :) 我正在使用Newtosoft.Json来解析JSON,这在C#中非常正常:)

Unfortunately I got a json string like following to parse: 不幸的是我得到了一个json字符串,如下面的解析:

{"data": {"str_1": "' \u001e\v \u0003\u001f"\u0003\u001d %\b)\v#"}}

Calling JObject.Parse(aboveLine) gives me an error like Bad JSON escape sequence: \\v. Path 'data.str_1', line 1, position [number]. 调用JObject.Parse(aboveLine)给我一个像Bad JSON escape sequence: \\v. Path 'data.str_1', line 1, position [number].的错误Bad JSON escape sequence: \\v. Path 'data.str_1', line 1, position [number]. Bad JSON escape sequence: \\v. Path 'data.str_1', line 1, position [number]. \\v is a sign for vertical line. \\v是垂直线的标志。

Is there a way how can I parse above json without exception? 有没有办法如何解析json以上无异常?

I checked the specification and I found that '\\v' is a valid JSON. 我检查了规范,发现'\\ v'是一个有效的JSON。 The specification is available here: https://www.json.com/json-object#object-with-strings 该规范可在此处获得: https//www.json.com/json-object#object-with-strings

I also checked the source code an it does not support '\\v'. 我还检查了源代码,它不支持'\\ v'。 That is why I created pull request which I hope will be merged into Newtonsoft.Json: https://github.com/JamesNK/Newtonsoft.Json/pull/489 这就是我创建pull请求的原因,我希望将其合并到Newtonsoft.Json中: https//github.com/JamesNK/Newtonsoft.Json/pull/489

Update 更新

Unfortunately for me http://json.com is WRONG and \\v is not a valid backlash char in JSON. 对我来说不幸的是http://json.com是错误的并且\\v在JSON中不是有效的反弹字符。 The RFC 4627 specifies all of them and \\v is not in it :( I added comment about this on http://json.com RFC 4627指定了所有这些并且\\v不在其中:(我在http://json.com上添加了对此的评论

Update 2 更新2

I described this story on my blog with all details. 我在博客上描述了这个故事的所有细节。 If you are interested just chek it out: http://stapp.space/bad-json-escape-sequence-v/ 如果您有兴趣,请将其解决: http//stapp.space/bad-json-escape-sequence-v/

Use \ (vertical tab) instead of \\v and you'll have a valid JSON. 使用\ (垂直制表符)代替\\v ,您将拥有有效的JSON。

\\v is a sign for vertical line \\ v是垂直线的标志

\| is the vertical line | \|是垂直线|

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM