public override T ReadJson(JsonReader reader, T existingValue, JsonSerializer serializer) { var jsonObject = JObject.Load(reader); JToken token; T value; if (!jsonObject.TryGetValue("$wrappedType", out token)) { //The static _canRead is a terrible hack to get around the serialization loop... _canRead = false; value = jsonObject.ToObject <T>(serializer); _canRead = true; return(value); } var typeName = jsonObject.GetValue("$wrappedType").Value <string>(); var type = JsonExtensions.GetTypeFromJsonTypeName(typeName, serializer.Binder); var converter = serializer.Converters.FirstOrDefault(c => c.CanConvert(type) && c.CanRead); var wrappedObjectReader = jsonObject.GetValue("$wrappedValue").CreateReader(); wrappedObjectReader.Read(); if (converter == null) { _canRead = false; value = (T)serializer.Deserialize(wrappedObjectReader, type); _canRead = true; } else { value = (T)converter.ReadJson(wrappedObjectReader, type, existingValue, serializer); } return(value); }