为什么JSON空字符串在服务器端反序列化为null?

jwa*_*zko 10 c# asp.net-mvc json

我通过$ .post发送空字符串,并将其反序列化为null.如何在客户端区分字符串是空还是空?

问候

更新 我实际做的是:

$.post("Controller/Action", $.param({Name: ""}, true), null, "json");
Run Code Online (Sandbox Code Playgroud)

在服务器上:

public Container
{
   public string Name;
}

public void Action(Container container)
{
    bool c = container.Name == null;   // c is true, why ?     
}
Run Code Online (Sandbox Code Playgroud)

fri*_*sco 2

具有空值的变量在 JSON 中写为:

{ "var" : "" }
Run Code Online (Sandbox Code Playgroud)

空字符串被解析为 null,因为其中没有定义对象。