JSON.NET Error Self referencing loop detected for type

后端 未结 25 2878
我在风中等你
我在风中等你 2020-11-22 02:16

I tried to serialize POCO class that was automatically generated from Entity Data Model .edmx and when I used

JsonConvert.SerializeObject 

25条回答
  •  无人及你
    2020-11-22 02:28

    People have already talked about [JsonIgnore] being added to the virtual property in the class, for example:

    [JsonIgnore]
    public virtual Project Project { get; set; }
    

    I will also share another option, [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] which omits the property from serialization only if it is null:

    [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
    public virtual Project Project { get; set; }
    

提交回复
热议问题