neuecc / Utf8Json

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

Deserializing a boolean string is throwing exception #160

Closed libardoabella closed 4 years ago

libardoabella commented 5 years ago

When deserializing a json string with a boolean value like:

{"active": "true"}

I am getting the following error:

Utf8Json.JsonParsingException: expected:'true | false', actual:'"true"'

which I believe is due to the fact that "true" is enclosed in quotes, instead of just being

{"active": true }

Since this is information I am obtaining froma REST API from a particular website, I have no control of the data that is coming in.

Is there anyway I can work around this? I have attempted to extend the BooleanFormatter class so I can provide a custom BooleanFormatter, but since the class is sealed, I can't seem to do much.

Any help would be quite appreciated!

Thanks.

libardoabella commented 4 years ago

Closing due to inactivity