[英]How to convert IEnumerable<CustomType> to List, applying grouping logic, and convert back to IEnumerable<CustomType>?
[英]Deserialize to IEnumerable<IEnumerable<CustomType>>
谁能帮我将json反序列化为IEnumerable<IEnumerable<CustomType>>
我有一个JSON对象,如下所示:
[
[{"Role" : "RoleA"},{"Role" : "RoleB"}],
[{"Role" : "RoleC"}],
[{"Buyer" : "UserA"}]
]
我如何反序列化为IEnumerable<IEnumerable<CustomType>>
,其中CustomType
为
public class CustomType
{
public string Type { get; set; }
public string Value { get; set; }
public Dictionary<string, string> AsJsonProperty()
{
return new Dictionary<string, string>
{
{Type, Value}
};
}
}
您不能反序列化接口。 请记住,它们实际上只是类实施的合同。 相反,您应该使用一个具体的类,例如List<>
:
JsonConvert.DeserializeObject<List<List<CustomClaimData>>>(metaData["ReadClaims"]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.