Tornhoof / SpanJson

SpanJson is a JSON serializer for .NET Core 6.0+
MIT License
425 stars 41 forks source link

Can't deserialize from json to class inheriting another class #190

Closed Aangbaeck closed 1 year ago

Aangbaeck commented 1 year ago

I get an error when I try to deserialize from json to a simple POCO-class inheriting properties from a base class (that I would like to populate as well).

SpanJson.JsonParserException: 'Error Reading JSON data: 'ExpectedDoubleQuote' at position: '45'.

Is there a way around this? Newtonsoft handles it well but I would like the speed of SpanJson.

Tornhoof commented 1 year ago

Please provide steps to reproduce your Problem.

Aangbaeck commented 1 year ago

Ok, it seem to be able to handle polymorphism. I found the issue though. It's the difference in the formatting of the json.

myJson: "{\"IsStocked\":false,\"PARTNO\":\"0\",\"COMPNO\":33}"

spanJSON: "{\"IsStocked\":\"false\",\"PARTNO\":\"0\",\"COMPNO\":33}"

Seems like booleans have double quotes "true" instead of the ordinary true.

Tornhoof commented 1 year ago

Then the type of your IsStocked is not bool

Aangbaeck commented 1 year ago

Ahh, of course... I will find my way out myself... :D Thanks!!