I have some JSON that I want to deserialize into an instance of a C# class. However, the class does not have all the fields/properties matching the original JSON. I would like to be able to modify the property values in the class and then serialize it back to JSON with the remaining fields and properties from the original JSON still intact.
For example, let's say I have the following JSON:
{
"name": "david",
"age": 100,
"sex": "M",
"address": "far far away"
}
And I want to deserialize it into this class:
class MyClass
{
public string name { get; set; }
public int age { get; set; }
}
After deserializing, I set the following:
myClass.name = "John";
myClass.age = 200;
Now, I want to serialize it back to JSON and get this result:
{
"name": "John",
"age": 200,
"sex": "M",
"address": "far far away"
}
Is there a way to do this using Json.Net?