diff --git a/ICD.Common.Utils/Json/AbstractGenericJsonConverter.cs b/ICD.Common.Utils/Json/AbstractGenericJsonConverter.cs index e5a84e9..fd51bab 100644 --- a/ICD.Common.Utils/Json/AbstractGenericJsonConverter.cs +++ b/ICD.Common.Utils/Json/AbstractGenericJsonConverter.cs @@ -56,6 +56,17 @@ namespace ICD.Common.Utils.Json return; } + WriteObject(writer, value, serializer); + } + + /// + /// Override to write the object value to the writer. + /// + /// + /// + /// + protected virtual void WriteObject(JsonWriter writer, T value, JsonSerializer serializer) + { writer.WriteStartObject(); { WriteProperties(writer, value, serializer); @@ -119,6 +130,17 @@ namespace ICD.Common.Utils.Json if (reader.TokenType != JsonToken.StartObject) throw new FormatException(string.Format("Expected {0} got {1}", JsonToken.StartObject, reader.TokenType)); + return ReadObject(reader, serializer); + } + + /// + /// Override to handle deserialization of the current StartObject token. + /// + /// + /// + /// + protected virtual T ReadObject(JsonReader reader, JsonSerializer serializer) + { T output = Instantiate(); reader.ReadObject(serializer, (p, r, s) => ReadProperty(p, r, output, s));