title: How to default a null JSON property to an empty array during serialization with a List<T> property in JSON.NET?
body: <p>Currently I have JSON that either comes in via an HTTP call or is stored in a database but during server processing they are mapped to C# objects.</p>
  
  <p>These objects have properties like <code>public List&lt;int&gt; MyArray</code>.</p>
  
  <p>When the JSON contains <code>MyArray:null</code> I want the resulting property to be an empty <code>List&lt;T&gt;</code> instead of a null <code>List&lt;T&gt;</code> property.</p>
  
  <p>The goal is that the object will "reserialize" to JSON as <code>MyArray:[]</code>, thus either saving to the database or responding out via HTTP as an empty array instead of <code>null</code>.</p>
  
  <p>That way, no matter what, the C# class is basically scrubbing and enforcing an empty array for any <code>List&lt;T&gt;</code> property that would otherwise be <code>null</code> and cause things to break in the browser side code (for example: <code>cannot read property 'length' of null</code>).</p>
  
  <p>Is there a way that during the serialization/deserialization I can have any null value that is paired to a <code>List&lt;T&gt;</code> property become an empty array instead?</p>