How to default a null JSON property to an empty array during serialization with a List<T> property in JSON.NET?
问题 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. These objects have properties like public List<int> MyArray . When the JSON contains MyArray:null I want the resulting property to be an empty List<T> instead of a null List<T> property. The goal is that the object will "reserialize" to JSON as MyArray:[] , thus either saving to the database or responding out via HTTP as an empty array instead of