Can anyone help me how to deserialize a json to IEnumerable<IEnumerable<CustomType>>
I have a JSON object as shown below:
[
[{"Role" : "RoleA"},{"Role" : "RoleB"}],
[{"Role" : "RoleC"}],
[{"Buyer" : "UserA"}]
]
How do I deserialize to IEnumerable<IEnumerable<CustomType>>
where CustomType
is
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}
};
}
}
You cannot deserialise to an interface. Remember that they are effectively just a contract for a class to implement. Instead you should use a concrete class, such as List<>
:
JsonConvert.DeserializeObject<List<List<CustomClaimData>>>(metaData["ReadClaims"]);