简体   繁体   中英

Newtosoft.Json Bad JSON escape sequence: \v.

I am using Newtosoft.Json for parsing JSON, which is quite normal in C# :)

Unfortunately I got a json string like following to parse:

{"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]. Bad JSON escape sequence: \\v. Path 'data.str_1', line 1, position [number]. \\v is a sign for vertical line.

Is there a way how can I parse above json without exception?

I checked the specification and I found that '\\v' is a valid JSON. The specification is available here: https://www.json.com/json-object#object-with-strings

I also checked the source code an it does not support '\\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

Update

Unfortunately for me http://json.com is WRONG and \\v is not a valid backlash char in JSON. The RFC 4627 specifies all of them and \\v is not in it :( I added comment about this on http://json.com

Update 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/

Use \ (vertical tab) instead of \\v and you'll have a valid JSON.

\\v is a sign for vertical line

\| is the vertical line |

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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