简体   繁体   English

请求正文列表 <KeyValuePair<string,string> &gt;

[英]Request Body List<KeyValuePair<string,string>>

I have WebService with the following method's: 我的WebService具有以下方法:

[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
string PostList(List<string> arr);

The RequestBody of the method is: 该方法的RequestBody是:

{"arr" : ["somestring1", "somestring2"]}

Now, I want another web method like that: 现在,我想要另一个这样的网络方法:

[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
string PostListKVP(List<KeyValuePair<string, string>> arr);

How does the JSON RequestBody should be for this WebMethod? 此WebMethod的JSON RequestBody应该如何?

Thanks. 谢谢。

As @Dmytro Shevchenko suggest i replace to Dictionary<string,string> like the follow: 正如@Dmytro Shevchenko建议的那样,我将其替换为Dictionary<string,string> ,如下所示:

[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
string PostDictionary(Dictionary<string, string> arr);

And the requestbody is: 请求主体是:

{"str" : [{"Key":1,"Value":2},{"Key":2,"Value":3}]}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM