I have a class like this:
public class Event
{
[JsonProperty(PropertyName = "_id")]
public string Id { get; set; }
[JsonProperty(PropertyName = "status"]
public string Status { get; set; }
}
I am receiving JSON that looks like this:
[
{
"_id": 4,
"status": "started"
},
{
"_id": 117841261,
"status": {
"_statusid": 1,
"date": "01.01.2015"
}
}
]
Please be aware: in the first object, the status field is a string. In the second object, it's an object. In my object it's a string property. I want to parse it whenever the status field is a string. I'm okay with skipping it when it's an object like in the second object.
I have tried changing the defaultValueHanding
options in the JsonProperty
attribute, but it didn't help. Is there any way to achieve this?