I'm trying to read a JSON document from a REST web service with Newsoft.JsonNET
The document contains some empty arrays:
{
"values": [null]
}
This is how a filled array looks like:
{
"values": ["first", "second", "third"]
}
My model class looks like this:
[DataContract]
public class MyModel
{
[DataMember]
public IEnumerable<MyEnum> Values{ get; }
public MyModel(IEnumerable<MyEnum> values)
{
this.Values = values;
}
}
public MyEnum
{
First,
Second,
Third
}
The null in those empty array causes an ArgumentNullException.
How can I solve this?