0

I have many serialized objects that have a $type property that I'd like to deserialize. However, I want to tell Newtonsoft to map to different type depending on the value of $type,

How can I do this?

E.g.

{
    "$type": "A.B.C, A.B",
    "MyProp": "MyValue"
}

I'd like Newtonsoft to interpret this as:

{
    "$type": "A.B.D, A.B",
    "MyProp": "MyValue"
}
MrPanucci
  • 497
  • 2
  • 11
  • Sure, you can use a [custom serialization binder](https://www.newtonsoft.com/json/help/html/SerializeSerializationBinder.htm). See [Using a custom type discriminator to tell JSON.net which type of a class hierarchy to deserialize](https://stackoverflow.com/q/11099466/3744182). Do the answers to that question fully answer your question also, or do you need something more specific? – dbc Jan 21 '21 at 18:10
  • 1
    That's exactly what I'm looking for - thanks. If you post as an answer I'll accept it. – MrPanucci Jan 22 '21 at 08:29

0 Answers0