簡體   English   中英

反序列化為IEnumerable <IEnumerable<CustomType> &gt;

[英]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>>>(metaDat‌​a["ReadClaims"]);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM