using System.Collections.Generic;
public static void Main()
DataMapList dml = new DataMapList();
string json = JsonConvert.SerializeObject(dml, Formatting.Indented);
[JsonConverter(typeof(DataMapListSerializer))]
public List<Dictionary<object, object>> employeeSalaryMappingList = null;
employeeSalaryMappingList = new List<Dictionary<object, object>>();
employeeSalaryMappingList.Add(new Dictionary<object, object>());
employeeSalaryMappingList[0].Add(1, 10000);
employeeSalaryMappingList[0].Add(2, 13000);
employeeSalaryMappingList[0].Add(3, 15000);
employeeSalaryMappingList.Add(new Dictionary<object, object>());
employeeSalaryMappingList[1].Add(4, 9000);
employeeSalaryMappingList[1].Add(5, 12000);
employeeSalaryMappingList[1].Add(6, 11000);
public class DataMapListSerializer : JsonConverter
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
var employeeSalaryDataMapList = value as DataMapList;
var employeeSalaryMappingList = employeeSalaryDataMapList.employeeSalaryMappingList;
writer.WriteStartArray();
foreach (var employeeSalaryMappingDictionary in employeeSalaryMappingList)
writer.WriteStartObject();
writer.WritePropertyName("ED");
writer.WriteStartObject();
foreach (var keyValuePair in employeeSalaryMappingDictionary)
writer.WritePropertyName("ID-" + keyValuePair.Key);
serializer.Serialize(writer, keyValuePair.Value);
public override bool CanConvert(Type objectType)
return typeof(DataMapList).IsAssignableFrom(objectType);
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
throw new NotImplementedException();