System.Text.Json custom descriminator that isn't the first field?

23 views Asked by At

I have some JSON retrieved from a database that I cannot alter. I want to polymorphically deserialise based on a field in the object. I understand I can supply a custom name via the attribute [JsonPolymorphic(TypeDiscriminatorPropertyName = "$discriminator")] but this complains as the field I want to use is not the first of the object. Is my only option here a full custom converter or is there a simpler way to just specify the field I want when it's not the first?

0

There are 0 answers