WCF - POST JSON字典没有键/值文本字典、文本、WCF、POST

2023-09-06 14:07:03 作者:若能再次相爱

我有一个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?

推荐答案

您将不得不编写您自己的包装。

You will have to write your own wrapper.