Ниже Json строкаНевозможно преобразовать строку в объект JSON
{
"Resources": {
"Resource": [
{
"ResourceId": "D513E96F-EA6C-E511-8133-000D3A0044F4",
"MSPSLogin": "richa.dinesh.parkar",
"Email": "[email protected]"
},
{
"ResourceId": "D513E96F-EA6C-E511-8133-000D3A0044F4",
"MSPSLogin": "harshal.arun.vadnere",
"Email ": "[email protected]"
}
]
},
"CreatedOn":"2016-07-18T12:51:14.23Z",
"CreatedByApp":"AD"
}
Мой класс в моделях:
public class Resource
{
public string ResourceId { get; set; }
public string MSPSLogin { get; set; }
public string Email { get; set; }
}
public class Resources
{
public IList<Resource> Resource { get; set; }
}
public class Example
{
public Resources Resources { get; set; }
public DateTime CreatedOn { get; set; }
public string CreatedByApp { get; set; }
}
Я использую Json.NET, я хочу, чтобы преобразовать строку ниже Json Object.
Example example = JsonConvert.DeserializeObject<Example>(jsonstr);
Но ошибка:
An unhandled exception of type 'Newtonsoft.Json.JsonSerializationException' occurred in Newtonsoft.Json.dll
Additional information: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[myWizard_MSPS_integration.Example]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
[Ваш код, кажется, УНР k fine] (https://dotnetfiddle.net/d8VuSX), когда я пытаюсь. –