![](/img/trans.png)
[英]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.