2014-11-24 107 views

回答

1

您可以指定settings

var settings = new Newtonsoft.Json.JsonSerializerSettings { 
    NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore}; 

和使用,在各種串行構造函數和序列化的呼叫。

或者,IIRC它支持conditional serialization,即

public bool ShouldSerializeFoo() { return Foo != null; } 
// pairs to property Foo 
1

嘗試將該屬性與JsonProperty attribute

[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 
public SaleLines SaleLines { get; set; } 
標記