I have different backends giving back almost the same JSON data model except for a nested json object with the id
field which sometimes can be a pure number such as:
{ "something": { "id": 1 } }
or a string, such as:
{ "something": { "id": "ex.GUID" } }
plus the model is made of nullables, different System
types and custom classes. And I would like those json numbers 1
to be set as"1"
always(so the C# class model has the this property as public string Id { get; set; }
), possibly for that precise property.
Is there any JsonConverter<T>
or property [Attribute]
that could handle carefully such parsing/deserialization?
ps: the current JsonConverter<object>
answers don't seem to handle well(exceptions) such scenario as described above