using System.Collections.Generic;
public static void Main()
var parameter = new Parameter
defaults = new List<object>
100, 350, 550, 800, 850, 1000, 1050, 1150, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2100, 2200, 2350, 2400, 2500, 2550
var settings = new JsonSerializerSettings
Converters = new List<JsonConverter> { new CustomFormattingArrayConverter(10) },
Formatting = Formatting.Indented
var json = JsonConvert.SerializeObject(parameter, settings);
public List<object> defaults { get; set; }
public class CustomFormattingArrayConverter : JsonConverter
private int ItemsPerLine { get; set; }
public CustomFormattingArrayConverter(int itemsPerLine)
if (itemsPerLine < 1) throw new ArgumentException("itemsPerLine must be 1 or more");
ItemsPerLine = itemsPerLine;
public override bool CanConvert(Type objectType)
return objectType == typeof(List<object>);
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
List<object> list = (List<object>)value;
writer.WriteStartArray();
for (int i = 0; i < list.Count; i++)
if (i % ItemsPerLine == 0) writer.Formatting = Formatting.Indented;
serializer.Serialize(writer, list[i]);
if (i % ItemsPerLine == 0) writer.Formatting = Formatting.None;
writer.Formatting = Formatting.Indented;
public override bool CanRead
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
throw new NotImplementedException();