I have a json like this:
{
"user": [
{
"det": [
{
"Code": "9",
"Description": "Update"
}
],
"arts": []
}
]
}
Now in some case the json that I reiceve contains the key arts
in other case this key isn't provided, so simply I have only the json with the det
key as:
{
"user": [
{
"det": [
{
"Code": "9",
"Description": "Update"
}
]
}
]
}
and this is my class for deserializing it:
public class Det
{
public string Code { get; set; }
public string Description { get; set; }
}
public class Arts
{
public string ID { get; set; }
public string CON3 { get; set; }
}
public class user
{
public List<Det> det { get; set; }
public List<Arts> arts {get; set; }
}
public class RootObject
{
public List<Det> user { get; set; }
}
So when I receive the first json the code working well, but when I receive the second the code fall in exception:
Cannot deserialize the current JSON object
This because the arts
key isn't provided but there is only the det
key. So there is a way to tell to my code to ignore arts
if is not setted? How can I do this? Thanks.