using System.Collections.Generic;
using Newtonsoft.Json.Linq;
public static void Main()
""Start_Date"": ""10/13/2012"",
""End_Date"": ""11/12/2012"",
""<img src=\""/includes/images/Icon_done.gif\"" border=\""0\"" alt=\""Done\"" title=\""Done\"" />""
""<img src=\""/includes/images/Icon_InProcess.gif\"" border=\""0\"" alt=\""In Process\"" title=\""In Process\"" />""
var settings = new JsonSerializerSettings
DateFormatString = "MM/dd/yyyy"
var model = JsonConvert.DeserializeObject<myModel>(json, settings);
public int ID { get; set; }
public int Days { get; set; }
[JsonProperty("Start_Date")]
public DateTime StartDate { get; set; }
[JsonProperty("End_Date")]
public DateTime EndDate { get; set; }
public string State { get; set; }
public string Page { get; set; }
public string Test { get; set; }
public List<ChildModel> Rows { get; set; }
[JsonConverter(typeof(ArrayToObjectConverter<ChildModel>))]
public int ID { get; set; }
public string StatusId { get; set; }
public DateTime ContactDate { get; set; }
public string State { get; set; }
public string Status { get; set; }
public string CustomerName { get; set; }
public DateTime WorkStartDate { get; set; }
public DateTime WorkEndDate { get; set; }
public string Territory { get; set; }
public string CustType { get; set; }
public int JobOrder { get; set; }
public string Link { get; set; }
class JsonArrayIndexAttribute : Attribute
public int Index { get; private set; }
public JsonArrayIndexAttribute(int index)
class ArrayToObjectConverter<T> : JsonConverter where T : class, new()
public override bool CanConvert(Type objectType)
return objectType == typeof(T);
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
JArray array = JArray.Load(reader);
var propsByIndex = typeof(T).GetProperties()
.Where(p => p.CanRead && p.CanWrite && p.GetCustomAttribute<JsonArrayIndexAttribute>() != null)
.ToDictionary(p => p.GetCustomAttribute<JsonArrayIndexAttribute>().Index);
JObject obj = new JObject(array
return propsByIndex.TryGetValue(i, out prop) ? new JProperty(prop.Name, jt) : null;
serializer.Populate(obj.CreateReader(), target);
public override bool CanWrite
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
throw new NotImplementedException();