I'm creating a WCF service that will accept data that looks like this:
[DataContract]
public class Payload
{
[DataMember]
public string Prop1 { get; set; }
[DataMember]
public string Prop2 { get; set; }
[DataMember]
public List<Dictionary<string,string>> Prop3 { get; set; }
}
However, when I submit this data:
{"Prop1":"A","Prop2":"B","Prop3":[{"Prop4":"D","Prop5":"E"},{"Prop6":"F","Prop7":"G"}]}
The deserialized object has Prop1
and Prop2
filled out correctly, and Prop3
contains two Dictionary
objects - but both Dictionaries
are empty.
I also changed Prop3 to use an internal class:
public List<PayloadData> Prop3 { get; set; }
[DataContract]
public class PayloadData : ISerializable, IEnumerable<KeyValuePair<string,string>>
{
private readonly Dictionary<string,string> _dict;
public PayloadData()
{
_dict = new Dictionary<string,string>();
}
...
}
This had the same result. I also tried making the PayloadData
class implement both ICollection<KeyValuePair<string,string>>
and IDictionary<string,string>
with no luck.