Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/440.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在json序列化期间忽略对象属性_C#_Javascript_Json_Model View Controller - Fatal编程技术网

C# 在json序列化期间忽略对象属性

C# 在json序列化期间忽略对象属性,c#,javascript,json,model-view-controller,C#,Javascript,Json,Model View Controller,我使用的是MVC控制器。Json方法,以便将Json结果对象发送到我的javascript函数 有时我想从json结果对象中省略对象的一个属性 我怎样才能做到 这是我的.NET对象: public class jsTreeModel { public string Data { get; set; } public JsTreeAttribute Att { get; set; } public string State { get

我使用的是MVC控制器。Json方法,以便将Json结果对象发送到我的javascript函数

有时我想从json结果对象中省略对象的一个属性

我怎样才能做到

这是我的.NET对象:

    public class jsTreeModel
    {
        public string Data { get; set; }
        public JsTreeAttribute Att { get; set; }
        public string State { get; set; }
        public List<jsTreeModel> Children { get; set; }
    }
在这种情况下,我想从json结果中省略'Children'属性


有什么想法吗?

如果您使用Json.NET作为序列化程序,您可以非常简单地省略一个属性:

public class jsTreeModel
{
    public string Data { get; set; }
    public JsTreeAttribute Att { get; set; }
    public string State { get; set; }
    [JsonIgnore]
    public List<jsTreeModel> Children { get; set; }
}

我希望这对你有帮助

如果您使用Json.NET作为序列化程序,您可以非常简单地省略一个属性:

public class jsTreeModel
{
    public string Data { get; set; }
    public JsTreeAttribute Att { get; set; }
    public string State { get; set; }
    [JsonIgnore]
    public List<jsTreeModel> Children { get; set; }
}
我希望这对你有帮助

看起来像个傻瓜看起来像个傻瓜