using System.Collections.Generic;
public static void Main()
var group = new ElementGroup
Elements = new List<Element>
Coordinates = new List<List<double>>
new List<double> { 1.1, 1.2, 1.3 },
new List<double> { 2.1, 2.2, 2.3 },
new List<double> { 3.1, 3.2, 3.3 }
Indices = new List<int> { 1, 2, 3, 4, 6, 7, 8, 10 },
Coordinates = new List<List<double>>
new List<double> { 4.1, 4.2, 4.3 },
new List<double> { 5.1, 5.2, 5.3 },
new List<double> { 6.1, 6.2, 6.3 }
Indices = new List<int> { 3, 5, 7, 8, 9, 11, 18, 20 },
string json = JsonHelper.SerializeWithCustomIndenting(group);
public static class JsonHelper
public static string SerializeWithCustomIndenting(object obj)
using (StringWriter sw = new StringWriter())
using (JsonWriter jw = new CustomJsonTextWriter(sw))
jw.Formatting = Formatting.Indented;
JsonSerializer ser = new JsonSerializer();
public class CustomJsonTextWriter : JsonTextWriter
public CustomJsonTextWriter(TextWriter writer) : base(writer)
protected override void WriteIndent()
if (WriteState != WriteState.Array)
public class ElementGroup
public string Name { get; set; }
public List<Element> Elements { get; set; }
public string Name { get; set; }
public List<List<double>> Coordinates { get; set; }
public List<int> Indices { get; set; }
public double Volume { get; set; }
public double Voids { get; set; }
public string Type { get; set; }
public string Guid { get; set; }
public string Quality { get; set; }