using System; using System.Collections.Generic; using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace Generators.Data { public class CanonicalDataCaseJsonConverter : JsonConverter { public override bool CanConvert(Type objectType) { return typeof(CanonicalDataCase) == objectType; } public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var jToken = JToken.ReadFrom(reader); var canonicalDataCase = new CanonicalDataCase(); serializer.Populate(new JTokenReader(jToken), canonicalDataCase); canonicalDataCase.Data = jToken.ToObject>(); return canonicalDataCase; } public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { throw new NotImplementedException(); } } }