As a basic example of my situation, lets say I have a class (UserInfo) with two properties. One is Username string, the other named Demographics is a dictionary. The class is marked with DataContract and the props are marked with DataMember. I have an OperationContract in my WCF service that returns my object as JSON. When a request hits and my object is returned it is being serialized as:
{"UserName":"Bobby", "Demographics" : [{"Key": "1", "Value": "Blah1"},{"Key": "2", "Value": "Blah2"}]}
The Demographics is being returned as an array. I want it to be returned as a list. Meaning the bracket should be removed, like this:
EDIT I wrote that object incorrectly
{"Username": "Bobby",
"Demographics": {
"Key1": {
"Value": "Blah1"
},
"Key2": {
"Value": "Blah2"
}
}
}
My operation contract is:
[OperationContract]
[WebInvoke(UriTemplate = "GetNewUserFields",
ResponseFormat = WebMessageFormat.Json,
Method = "GET"),
Description("Get the Fields needed for a new user")]
UserInfo GetNewUserFields();
Is there any way to do this? I would post direct code example, however the classes that I am serializing are actually much more complex than what I have described and the return result posted here would be a mess of data to sift through.
Thank you for any help that you may provide.