neuecc / Utf8Json

Definitely Fastest and Zero Allocation JSON Serializer for C#(NET, .NET Core, Unity, Xamarin).
MIT License
2.36k stars 267 forks source link

Deserializing string with escaped backslash fails #121

Open brotherBear opened 5 years ago

brotherBear commented 5 years ago
{
    "attr_x": "C:\\some gx\\",
    "attr_v": 30
}

It doesn't matter what the target C# object is. The error is related to the gx\\" part, and the deserializer apparently can't identify the double-quote because of the escaped back-slash.

This yields the following error response:

System.AggregateException : One or more errors occurred.
  ----> Utf8Json.JsonParsingException : expected:',', actual:'a', at offset:40
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
.....
--JsonParsingException
   at Utf8Json.JsonReader.ReadIsValueSeparatorWithVerify()
   at Utf8Json.JsonReader.ReadIsEndObjectWithSkipValueSeparator(Int32& count)

If I modify the input JSON to:

{
    "attr_x": "C:\\some gx\\"
}

the resulting error is:

System.AggregateException : One or more errors occurred.
  ----> Utf8Json.JsonParsingException : not found end string.
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
.....
--JsonParsingException
   at Utf8Json.JsonReader.ReadNextCore(JsonToken token)
   at Utf8Json.JsonReader.ReadNextBlockCore(Int32 stack)

In both cases, if I modify the gx\\" to gx" all the tests are green.

_Originally posted by @brotherBear in https://github.com/neuecc/Utf8Json/issue_comments#issuecomment-432936975_

buybackoff commented 5 years ago

See #63 and #96