3using Newtonsoft.Json.Linq;
23 return typeof(T).IsAssignableFrom(objectType);
38 JsonSerializer serializer)
40 if (reader.TokenType == JsonToken.Null)
44 JObject jObject = JObject.Load(reader);
47 T target =
Create(objectType, jObject);
50 using (JsonReader jObjectReader =
53 serializer.Populate(jObjectReader, target);
68 JsonSerializer serializer)
70 serializer.Serialize(writer, value);
79 protected abstract T
Create(Type objectType, JObject jObject);
Json converter helper class.
T Create(Type objectType, JObject jObject)
Create an instance of objectType, based properties in the JSON object.
override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
Parses the json to the specified type.
override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
Serializes to the specified type.
static JsonReader CopyReaderForObject(JsonReader reader, JObject jObject)
Creates a new reader for the specified jObject by copying the settings from an existing reader.
override bool CanConvert(Type objectType)
Determines if this converter is designed for deserialization to objects of the specified type.