I am trying to write a generic pattern to deserialize my json array string. i have the following object created bellow:
public interface IDataResponse<T> where T: class
{
List<T> Data { get; set; }
}
public class DataResponse<T>: IDataResponse<T> where T: class
{
[JsonProperty("value")]
public List<T> Data { get; set; }
}
My json format
{
"values":{
"value":[
{
"value_1":"aaaaaa",
"value_2":"aaaaaa",
"value_3":"aaaaaa"
},
{
"value_1":"bbbbbb",
"value_2":"bbbbbb",
"value_3":"bbbbbb"
}
]
}
}
Now i can use this pattern like that
var myData = JsonConvert.DeserializeObject<List<DataResponse<MyData>>>(result);
where result is the json array string.
But ruuning this code , i got the exception bellow
Cannot deserialize the JSON array (e.g. [1,2,3]) into type ' ' because type requires JSON object (e.g. {“name”:“value”}) to deserialize correctly
How cani fix this error?