I have a collection class that inherits from List<T>
public class TestCollection : List<Test>
{
public virtual String SomeTestingDetail { get; set; }
}
Json.NET will serialize an array of test objects but leaves off the SomeTestingDetail property.
Is there a way to force this property to be serialized as well?
The JSON.net serializer converts a List into an array, and any properties directly in a collection will be ignored. From the Json.Net site “Because JSON arrays only support a range of values and not properties, any additional properties and fields declared on .NET collections are not serialized. ” A better way would be to use a class which the string property and a property which holds the list of items.
http://james.newtonking.com/projects/json/help/