/// <summary> /// Parses JSON read from the given text reader and converts it into /// an object of the given type. The resulting output can be cast /// safely to that given type. /// </summary> /// <param name="reader">The TextReader to read JSON from.</param> /// <param name="modelType">The type of the result object.</param> /// <returns>The result object. For class types, this can be null.</returns> public static object Parse(TextReader reader, Type modelType) { var consumer = new ModelJsonConsumer(ConverterRegistry.Get(modelType)); Parse(reader, consumer); return(consumer.Result); }
/// <summary> /// Converts this generic object model to another .NET object of the given <paramref name="type"/>. /// </summary> /// <param name="type">The type of the .NET object to convert to.</param> /// <returns>An instance of the given <paramref name="type"/>.</returns> public object ToModel(Type type) { var consumer = new ModelJsonConsumer(ConverterRegistry.Get(type)); Write(consumer); return(consumer.Result); }