C# DataContractJsonSerializer fails when value can be an array or a single item
问题 I use the DataContractJsonSerializer to parse a json string into a object hierarchie. The json string 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 of "attributes" can be an array or a single item. I found the code part where the problem occures: [DataContract] public class ItemGroup { [DataMember(Name="attributes")] public List