I have the below sample JSON:
[
{
"$type": "TestProject.Classes.TestClass, TestProject",
"Name": "TestCommand",
"Children": [
{
"Age": 0,
"Eta": 8,
"Gender": "Ragel"
},
{
"Age": 0,
"Eta": 20,
"Gender": "Mara"
}
],
"School": {
"Title": "School for Life"
}
}
]
This is deserialized from a data source (message in the message queue). There are some types which have changed in the codebase, and I would like to still be able to map the old types to the new ones.
For the example, let's imagine the type TestClass
no longer exists, but now is TestClassNew
. I have mappings stored to be able to map from the old to the new type. I am trying to alter the $type
value prior to the object being deserialised, such that its string value is changed from TestProject.Classes.TestClass, TestProject
to TestProject.Classes.TestClassNew, TestProject
.
I was trying using a JsonConvertor, but not sure if that is the right way - haven't managed to do it. Any help on how this can be done would be appreciated.