diff --git a/ICD.Common.Utils/Extensions/JsonExtensions.cs b/ICD.Common.Utils/Extensions/JsonExtensions.cs index 5bffe77..38bfa59 100644 --- a/ICD.Common.Utils/Extensions/JsonExtensions.cs +++ b/ICD.Common.Utils/Extensions/JsonExtensions.cs @@ -36,6 +36,38 @@ namespace ICD.Common.Utils.Extensions jObject.WriteTo(extends, converter); } + /// + /// Reads the current token in the reader and deserializes to the given type. + /// + /// + /// + /// + public static T ReadAsObject(this JsonReader extends) + { + if (extends == null) + throw new ArgumentNullException("extends"); + + JsonSerializer serializer = new JsonSerializer(); + return extends.ReadAsObject(serializer); + } + + /// + /// Reads the current token in the reader and deserializes to the given type. + /// + /// + /// + /// + public static T ReadAsObject(this JsonReader extends, JsonSerializer serializer) + { + if (extends == null) + throw new ArgumentNullException("extends"); + + if (serializer == null) + throw new ArgumentNullException("serializer"); + + return serializer.Deserialize(extends); + } + /// /// Writes the type value. ///