Here is my JSON
result from Postman
{
"result": [
{
"brands": [],
"services": [],
"addresses": [],
"accessPoints": [],
"Kodu": "100",
"name": "üeticissdss",
"taxNumber": "asd",
"taxOffice": "sada",
"id": "bfb064f4-0732-43ab-9d94-87f6934258fe",
"isActive": true
},
{
"brands": [],
"services": [],
"addresses": [],
"accessPoints": [],
"Kodu": "100",
"name": "üeticissdss",
"taxNumber": "asd",
"taxOffice": "sada",
"id": "bfb064f4-0732-43ab-9d94-87f69d4258fe",
"isActive": true
}
],
"id": 13,
"exception": null,
"status": 5,
"isCanceled": false,
"isCompleted": true,
"isCompletedSuccessfully": true,
"creationOptions": 0,
"asyncState": null,
"isFaulted": false
}
and I am trying to deserialize the json like below :
[BindProperty]
public List<Manufacturer> manufacturer { get; set; }
HttpClient httpClient = new HttpClient();
httpClient.BaseAddress = new Uri(apiParameters.HttpClientBaseAddress);
httpClient.DefaultRequestHeaders.Accept.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(apiParameters.DefaultRequestHeadersJson));
customIndexModel.ApiResponseMessage = await httpClient.GetAsync(apiParameters.HttpClientBaseAddress);
if (customIndexModel.ApiResponseMessage.IsSuccessStatusCode)
{
var jsonAsString = customIndexModel.ApiResponseMessage.Content.ReadAsStringAsync().Result;
manufacturer = JsonConvert.DeserializeObject<List<Manufacturer>>(jsonAsString);
}
the error message :
Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[Q.Entity.Manufacturer.Manufacturer]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly. To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object. Path 'result', line 1, position 10.
It looks like I'm miss something but I can not figure out. Could you help me please ?