I am using DataContractJsonSerializer to parse json string in object hierarchy. The json line looks like this:
{
"groups": [
{
"attributes": [
{
"sortOrder": "1",
"value": "A"
},
{
"sortOrder": "2",
"value": "B"
}
]
},
{
"attributes": {
"sortOrder": "1",
"value": "C"
}
}
]
}
As you can see, the sub value for the attributes can be an array or a single element. I found the part of the code where the problem occurs:
[DataContract]
public class ItemGroup
{
[DataMember(Name="attributes")]
public List<DetailItem> Items { get; set; }
}
This works for the first, but does not work in the second.
Does anyone have an answer to this question?
thank
source
share