嘿,我刚接触json对象需要一些帮助。代码位于以下链接中,错误消息为:
其他信息:无法反序列化当前的JSON对象 (例如{“name”:“value”})进入类型 'System.Collections.Generic.List
1[System.Collections.Generic.KeyValuePair
2 [System.String,System.Collections.Generic.IEnumerable`1 [LaiosIntranet.ExternalApis.HarvestApi + UserAssignment]]]' 因为该类型需要一个JSON数组(例如[1,2,3])来反序列化 正确。
这是UserAssignment的json文件。
{ “4812177”:[{ “ID”: “36849769”, “用户ID”: “431187”, “专案编号”: “4812177”, “HourlyRate”:300.0, “失活”:假 “IsProjectManager”:假, “CreatedAt”: “2014-01-10T17:30:24”, “UpdatedAt”: “2014-01-10T17:30:52”},{ “ID”: “36849771”, “用户ID”:“234084 “ ”专案编号“: ”4812177“, ”HourlyRate“:950.0, ”失活“:假 ”IsProjectManager“:假 ”CreatedAt“: ”2014-01-10T17:30:24“, ”UpdatedAt“:” 2014 -01-10T17:30:52 “},{” ID “:” 36849774" , “用户ID”: “149539”, “专案编号”: “4812177”, “HourlyRate”:950.0, “失活”:假“IsProjectManager “:假” CreatedAt “:” 2014-01-10T17:30:24" , “UpdatedAt”: “2014-01-10T17:30:52”},
这是UserAssignment
public class UserAssignment
{
public string Id { get; set; }
public string UserId { get; set; }
public string ProjectId { get; set; }
public double HourlyRate { get; set; }
public bool Deactivated { get; set; }
public bool IsProjectManager { get; set; }
public DateTime? CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
}