I’m using the System.Runtime.Serialization.Json library
This doesn’t Work
public class Detections
{
[DataContract]
public class RootObject
{
[DataMember(Name = "data")]
public DataObject Data { get; set; }
}
[DataContract]
public class DataObject
{
[DataMember(Name = "detections")]
public List<Detection> Detections { get; set; }
}
[DataContract]
public class Detection
{
[DataMember(Name = "language")]
public string Language { get; set; }
[DataMember(Name = "isReliable")]
public string IsReliable { get; set; }
[DataMember(Name = "confidence")]
public string Confidence { get; set; }
}
}
So how should I parse this
{
"data": {
"detections": [
[
{
"language": "tr",
"isReliable": false,
"confidence": 0.086520955
}
]
]
}
}
The problem is occurring for two reasons.
1) Your nested classes needed to be removed from within the Detections class.
2) The JSON contains a multi-dimensional array for the detections member where I assume it needs to be single.
I have tested the code detailed below it works fine.
I Hope this helps you.