Skip to content

Fallback to JSONPath to allow nested field as a deserialization property. #89

Description

@remgodow

I'd like to suggest an enhancement to support fallback to JSONPath when looking for property name and/or value.

Describe the solution you'd like
An ability to use nested field in json as a discriminator name (ex. data.field) for

[JsonConverter(typeof (JsonSubtypes), "data.field")]
    [JsonSubtypes.KnownSubType(typeof (SomeClass), "value")]

{
   data: {
     field: "value"
   }
}

It is useful when creating C# model for given API, which you cannot change.
Fallback to JSONPath requires minimal changes (using JObject.SelectToken(discriminatorName) when it had not been found using existing method).

I have implemented described changes in the library, it passes all unit tests, and I use the change in my project. I'd be glad to do the pull request if you'd accept this enhancement.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions