Is there some way to set what the default representation for null values should be in Json.NET? More specifically null values inside an array.
Given the class
public class Test
{
public object[] data = new object[3] { 1, null, "a" };
}
Then doing this
Test t = new Test();
string json = JsonConvert.SerializeObject(t);
Gives
{"data":[1,null,"a"]}
Is it possible to make it look like this?
{"data":[1,,"a"]}
Without using string.Replace.
Figured it out. I had to implement a custom JsonConverter. As others mentioned this will not produce valid/standard Json.
Use it like this