Json result returns Array of objects some times and a single object if single record exists.so i want to Parse the json result to my model class which is a list,so if json returns an array then its working fine..if it is a single object i m getting this error..
Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[Chefsportalen.Models.JsonObjectModels.ListDevicesByLabelModel+Device]' 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 'devices.device.@id', line 1, position 90.
public class listAllAppsModelcs
{
public string deviceUuid { get; set; }
public List<App> clientApps { get; set; }
public class App
{
public string @id { get; set; }
public string appName { get; set; }
public string assetName { get; set; }
public string bundle { get; set; }
public int inventoryAppId { get; set; }
public string platform { get; set; }
public object reportedAppName { get; set; }
public string type { get; set; }
public object version { get; set; }
}
public class Apps
{
public List<App> clientApp { get; set; }
}
}
this is my model class..
and my json responce is this
{
"deviceUuid": "dd77202b-ec50-4c0b-95d3-8c742d171d31",
"clientApps": {
"clientApp": {
"@id": "203131",
"appName": "MobileIron 6.2",
"assetName": "MobileIron 6.2",
"bundle": "com.mobileiron.phoneatwork",
"inventoryAppId": 6085,
"platform": "iOS 8.1",
"reportedAppName": "MobileIron",
"type": "APPLICATION",
"version": 6.2
}
}
}
Please Help me in fixing this issue..any help will be appriciated..thanks..