I'm using Newtonsoft.JSON and I have a JSON array where each array member is itself an array of two numbers, e.g.
{
"objList": [
[8.8, 4],
[9.2, 1.45],
[1.61, 32.79]
]
}
I want to deserialize this into a class MyObjList defined by
public class MyObjList {
[DataMember(Name = "objList")]
public List<MyObj> ObjList { get; set; }
}
where MyObj is the class
public class MyObj {
public double FirstDouble{ get; set; }
public double SecondDouble { get; set; }
}
I knew that more work was required, but just tying the above gave me a helpful error message that told me that I could put [JsonArrayAttribute]
on the MyObj class, i.e.
[JsonArrayAttribute]
public class MyObj{
public double FirstDouble{ get; set; }
public double SecondDouble { get; set; }
}
That has moved things on and the deserializer now fails at the next stage where it's looking for a suitable constructor. But I don't know how to write the constructor that is required and I can't find any examples. Can someone tell me how to do it?