POST JSON字典没有键/值文本 [英] POST JSON Dictionary without Key/Value Text
本文介绍了POST JSON字典没有键/值文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个WCF端点就是喜欢这样的:
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);
为了任何东西传递给我服务,我要组织我JSON像这样的:
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?
推荐答案
这对你的DoWork的参数更改为一个字符串,然后使用一个JSON解串器的方法,将其转换为相应格式的选项?
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?
这篇关于POST JSON字典没有键/值文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文