Open Galashek opened 1 year ago
We have the same problem here! Trying to switch to System.Text.Json but failing to do so because .NET throws an exception.
My suggestion would also have been to move the base-call to the top which would be sense anyways in my opinion (sub class should always override stuff of base classes). Is there any reason not to make this change?
System.Text.Json when deserializing polymorphic objects expects
$discriminator
to be at the start of the object (https://github.com/dotnet/runtime/issues/72604).In actual toJSON method template discriminator and base class properties are added to the JSON-object after the properties of the inheritor class.
Proposal is to change
Class.liquid
template by movingsuper.toJSON(data)
call to the start of toJSON method: