【问题标题】:Json parameters are passed as nullJson 参数作为 null 传递
【发布时间】:2012-03-12 12:50:48
【问题描述】:

我这样调用方法:

标题:

User-Agent: Fiddler
Content-type: application/json
Content-length: 116
Host: localhost:1234

POST方法,网址:

http://localhost:1234/MyService.svc/json/MyMethod

参数:

{"email":"here@hotmail.com","json":{"array1":[],"array2":[],"array3":[]}}

这是方法的签名:

public Result MyMethod(string email, Dictionary<string, object> json)

方法被调用。 email 的值还可以,但 json 的计数为零。为什么?

【问题讨论】:

  • 如果您将服务器端语言添加到标签中,请提供帮助!它还有助于展示您是如何生成 JOSN 的。
  • @HarHaHu 哦,我只是将手表添加到 json 中。它不为空,但不包含任何内容。
  • @epascarello 我没有生成 json。那就是json。可能是 {"email":"here@hotmail.com","json":{"some1":"some2"}}

标签: json


【解决方案1】:

我所做的是创建一个具有以下属性的新类:List、List、List,并且我更改了方法:

public void MyMethod(string email, theNewClass json) ;

它成功了。

【讨论】:

    猜你喜欢
    • 2014-11-17
    • 2018-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-11
    • 1970-01-01
    相关资源
    最近更新 更多