The problem is I have different types of objects (It know how to handle this with one type): Something like this:
{"myObjects": [
{
"Type":"sampleType1",
"Name":"sampleName1",
"Size":"sampleSize1"
},
{
"Type":"sampleType2",
"Name":"sampleName2",
"Size":"sampleSize2"
}
]
}
I handle with just:
JsonConvert.DeserializeObject<MyObjectContainer>(json);
where MyObjectContainer has a property:
public List<MyObjects> myObjects { get; set; }
The problem comes when I get an object with optional parameters:
{"myObjects": [
{
"Type":"sampleType1",
"Name":"sampleName1",
"Size":"sampleSize1"
},
{
"Type":"sampleType2",
"Name":"sampleName2",
"Size":"sampleSize2",
"AdditionalInfo":"AdditionalInfo"
}
]
}
To serialize it will be easy I think. I'll just create class AdditionalInfoObject : MyObject with property string AdditionalInfo.
But how to deserialize such json into my List?