using System.Collections.Generic;
using System.Globalization;
using Newtonsoft.Json.Linq;
public static void Main()
""status"": ""Reviewing"",
""2016-Mar-15 10:28 AM"": {
""shipping_address_1"": {
""from"": ""321 S Main St."",
""to"": ""8355 NW 74th St""
TransactionChangeLog changeLog = JsonConvert.DeserializeObject<TransactionChangeLog>(json);
Console.WriteLine("TransactionId: " + changeLog.TransactionId);
Console.WriteLine("TransactionStatus: " + changeLog.Status);
foreach (TransactionChange change in changeLog.Changelog)
Console.WriteLine(change.ChangeDate + " - changed " + change.Field + " from '" + change.From + "' to '" + change.To + "'");
public enum TransactionStatus { Reviewing, Approved }
public class TransactionChangeLog
[JsonProperty(PropertyName = "transaction_id")]
public int TransactionId { get; set; }
[JsonProperty(PropertyName = "status")]
public TransactionStatus Status { get; set; }
[JsonProperty(PropertyName = "changelog")]
[JsonConverter(typeof(ChangeLogConverter))]
public ICollection<TransactionChange> Changelog { get; set; }
public class TransactionChange
public DateTime ChangeDate { get; set; }
public string Field { get; set; }
public string From { get; set; }
public string To { get; set; }
public class ChangeLogConverter : JsonConverter
public override bool CanConvert(Type objectType)
return objectType == typeof(ICollection<TransactionChange>);
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
List<TransactionChange> changes = new List<TransactionChange>();
JObject changelog = JObject.Load(reader);
foreach (JProperty dateProp in changelog.Children<JProperty>())
DateTime changeDate = DateTime.ParseExact(dateProp.Name, "yyyy-MMM-dd hh:mm tt", CultureInfo.InvariantCulture);
foreach (JProperty fieldProp in dateProp.Value.Children<JProperty>())
TransactionChange change = new TransactionChange();
change.ChangeDate = changeDate;
change.Field = fieldProp.Name;
change.From = (string)fieldProp.Value["from"];
change.To = (string)fieldProp.Value["to"];
public override bool CanWrite
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
throw new NotImplementedException();