Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

POST JSON Dictionary without Key/Value Text

I have a WCF endpoint that is like such:

[OperationContract]
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json, UriTemplate = "")]
Stream DoWork(Dictionary<string, string> items);

In order to pass anything to my service, I have to structure my JSON like such:

{"items":[{"Key":"random1","Value":"value1"}, {"Key":"random2","Value":"value2"}]}

What I actually want it to look like is this:

{"items":{"random1":"value1","random2":"value2"}}

Is there any way to accomplish this?

like image 830
Brandon Avatar asked Dec 03 '11 23:12

Brandon


1 Answers

Is it an option for you to change the DoWork parameter to a string, then use a Json deserializer in the method to convert it to the appropriate format?

like image 102
competent_tech Avatar answered Oct 31 '22 11:10

competent_tech