0
есть ли способ десериализации списка сложных объектов в список типа ноу: EX:десериализации из списка сложных объектов в точный список Типа
public class Employee
{
public string EmployeeNumber { get; set; }
public string AccountName { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string PreferredName { get; set; }
public string Title { get; set; }
}
это объект, на котором я бы как десериализовать.
это, как я пытался :
var x = JsonConvert.DeserializeObject<List<Dictionary<string, IList<Employee>>>>(_content);
var x = JsonConvert.DeserializeObject<List<Dictionary<string, Employee>>>(_content);
var x = JsonConvert.DeserializeObject<List<Dictionary<string, Employee[]>>>(_content);
но я получаю это исключение
"ExceptionMessage": "Error converting value 37326 to type 'System.Collections.Generic.IList`1[Ubisoft.ECM.Events.Business.Providers.EmployeeProvider.Empoyee]'. Path '[0].EmployeeNumber', line 1, position 24.",
Внутреннее исключение:
"InnerException": {
"Message": "An error has occurred.",
"ExceptionMessage": "Could not cast or convert from System.Int64 to System.Collections.Generic.IList`1[Ubisoft.ECM.Events.Business.Providers.EmployeeProvider.Employee].",
"ExceptionType": "System.ArgumentException",
"StackTrace": " at Newtonsoft.Json.Utilities.ConvertUtils.EnsureTypeAssignable(Object value, Type initialType, Type targetType)\r\n at Newtonsoft.Json.Utilities.ConvertUtils.ConvertOrCast(Object initialValue, CultureInfo culture, Type targetType)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)"
}
Спасибо.
Проверили это вы? http://stackoverflow.com/questions/7895105/deserialize-json-with-c-sharp –
yep, он отлично работает, спасибо –