/// <summary> /// Deserialize the given JSON value according to the specified CLR type. /// </summary> /// <param name="type">The CLR type to deserialize the JSON value to.</param> /// <param name="jsonValue">The JSON value to deserialize.</param> /// <returns>The CLR object that the JSON value was deserialized from.</returns> public object DeserializeValue(Type type, JsonValue jsonValue) { if (ReferenceEquals(jsonValue, JsonNull.Instance)) { return(null); } var converter = JsonConverterFactory.CreateInstance(type); return(converter.DeserializeValue(this, type, jsonValue)); }
/// <summary> /// Serialize an inline object. /// </summary> /// <param name="value">The value to serialization inline.</param> /// <returns>The JSON value which represents the inline serialization of the value.</returns> public JsonValue SerializeValue(object value) { if (ReferenceEquals(value, null) || _visited.Contains(value)) { return(JsonNull.Instance); } _visited.Push(value); var type = value.GetType(); var converter = JsonConverterFactory.CreateInstance(type); var jsonValue = converter.SerializeValue(this, type, value); _visited.Pop(); return(jsonValue); }