title: Json.net ignore null values of child objects
body: <p>I am new into json.net, so any help would be appreciated.</p>
  
  <p><b> I am using the net 2.0 version of json.net, because i need to integrate it in Unity3d engine </b> Suggested answer (using nullvaluehandling) just don't work! Should i consider this as restiction of the oldest version?</p>
  
  <p>So, a have an object like this:</p>
  
  <pre><code>Object ()
  {
     ChildObject ChildObject1;
     ChildObject ChildObject2;
  }
  
  ChildObject ()
  {
     Property1;
     Property2;
  }
  </code></pre>
  
  <p>I want json.net to <b>serialize only not null properties of all objects, including child objects</b>. So if i instatiate only property1 of ChildObject1 and property2 of ChildObject2, the string from JsonConvert will be like this:</p>
  
  <pre><code>{
    "ChildObject1": 
          {
             "Property1": "10"
          },
    "ChildObject1": 
          {
            "Property2":"20"
          }
  }
  </code></pre>
  
  <p>But default behaviour creates string like this: </p>
  
  <pre><code>{
    "ChildObject1": 
             {
               "Property1": "10", 
               "Property2": "null" 
             },
    "ChildObject2": 
             {
               "Property1": "null, 
               "Property2":"20"
             }
  }
  </code></pre>
  
  <p><b>I know about NullValueHandling, but it is not working corretly in my case! It ignore only null properties of the parent object (object that we are serializing), but if this parent object has some childs, it will not ignore null properties of this child objects.</b> My situation is different.</p>
  
  <p>If even one property of a child object is not null, it serialize it to a string with one not-null property and others null.</p>
  
  <hr>
  
  <p>UPD example of my code: </p>
  
  <p>i have nested classes </p>
  
  <p>My object is like this:</p>
  
  <pre><code>public class SendedMessage
  {
      public List&lt;Answer&gt; Answers { get; set; }
      public AnswerItem Etalon {get; set;}
  }
  
  public class Answer () 
  {
  public AnswerItem Item { get; set; }
  }
  
     public class AnswerItem () 
     {
     public string ID { get; set; }
     public bool Result { get; set; }
     public int Number { get; set; }
     }
  </code></pre>
  
  <p>i instatiate a SendedMessage object like this:</p>
  
  <pre><code>new SendedMessage x;
  x.Etalon = new AnswerItem();
  x.Etalon.Result = true;
  </code></pre>
  
  <p>than i use</p>
  
  <pre><code>string ignored = JsonConvert.SerializeObject(x,
            Formatting.Indented,
            new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
  </code></pre>
  
  <p>and it make this string:</p>
  
  <p>{ "Etalon": {"ID" = "null", "Result" = "false", Number" = "null"}}</p>
  
  <p>so it really ignore the null object Answers (a List), but do not ignore the null properties of a child objects.</p>
  
  <p>Thanks for help!</p>