public static object DeserializeObject(char *chars, int length, Type type, JsonFormatterOptions options) { if ((options & JsonFormatterOptions.MultiReferencingReference) != 0) { var jsonDeserializer = new JsonReferenceDeserializer(chars, length); var result = ValueInterface.GetInterface(type).Read(jsonDeserializer); if (jsonDeserializer.references.Count != 0) { ReferenceInfo.ProcessReference(result, jsonDeserializer.references); if (jsonDeserializer.updateBase) { result = RWHelper.GetContent <object>(jsonDeserializer.writer); result = Convert.ChangeType(result, type); } } return(result); } return(DeserializeObject(chars, length, type)); }
public static T DeserializeObject <T>(string text, JsonFormatterOptions options) { if ((options & JsonFormatterOptions.MultiReferencingReference) != 0) { fixed(char *chars = text) { var jsonDeserializer = new JsonReferenceDeserializer(chars, 0, text.Length); var result = ValueInterface <T> .Content.ReadValue(jsonDeserializer); if (jsonDeserializer.references.Count != 0) { ReferenceInfo.ProcessReference(result, jsonDeserializer.references); if (jsonDeserializer.updateBase) { result = RWHelper.GetContent <T>(jsonDeserializer.writer); } } return(result); } } return(DeserializeObject <T>(text)); }
public object Deserialize(string text, Type type) { var options = Options; var id = Id; fixed(char *chars = text) { if ((options & JsonFormatterOptions.MultiReferencingReference) != 0) { var jsonDeserializer = new JsonReferenceDeserializer(chars, 0, text.Length); if (id != 0) { jsonDeserializer.id = id; } var result = ValueInterface.GetInterface(type).Read(jsonDeserializer); if (jsonDeserializer.references.Count != 0) { ReferenceInfo.ProcessReference(result, jsonDeserializer.references); if (jsonDeserializer.updateBase) { result = RWHelper.GetContent <object>(jsonDeserializer.writer); result = Convert.ChangeType(result, type); } } return(result); } else { var jsonDeserializer = new JsonDeserializer(chars, 0, text.Length); if (id != 0) { jsonDeserializer.id = id; } return(ValueInterface.GetInterface(type).Read(jsonDeserializer)); } } }
public T Deserialize <T>(string text) { var options = Options; var id = Id; fixed(char *chars = text) { if ((options & JsonFormatterOptions.MultiReferencingReference) != 0) { var jsonDeserializer = new JsonReferenceDeserializer(chars, 0, text.Length); if (id != 0) { jsonDeserializer.id = id; } var result = ValueInterface <T> .Content.ReadValue(jsonDeserializer); if (jsonDeserializer.references.Count != 0) { ReferenceInfo.ProcessReference(result, jsonDeserializer.references); if (jsonDeserializer.updateBase) { result = RWHelper.GetContent <T>(jsonDeserializer.writer); } } return(result); } else { var jsonDeserializer = new JsonDeserializer(chars, 0, text.Length); if (id != 0) { jsonDeserializer.id = id; } return(ValueInterface <T> .Content.ReadValue(jsonDeserializer)); } } }
/// <summary> /// 将 JSON 字符串反序列化为指定类型的值。 /// </summary> /// <typeparam name="T">指定类型</typeparam> /// <param name="chars">JSON 字符串</param> /// <param name="length">JSON 字符串长度</param> /// <returns>返回指定类型的值</returns> public T Deserialize <T>(char *chars, int length) { var options = Options; if ((options & JsonFormatterOptions.MultiReferencingReference) != 0) { var jsonDeserializer = new JsonReferenceDeserializer(chars, length); if (id != 0) { jsonDeserializer.jsonFormatter = this; } var result = ValueInterface <T> .ReadValue(jsonDeserializer); if (jsonDeserializer.references.Count != 0) { ReferenceInfo.ProcessReference(result, jsonDeserializer.references); if (jsonDeserializer.updateBase) { result = RWHelper.GetContent <T>(jsonDeserializer.writer); } } return(result); } else { var jsonDeserializer = new JsonDeserializer(chars, length); if (id != 0) { jsonDeserializer.jsonFormatter = this; } return(ValueInterface <T> .ReadValue(jsonDeserializer)); } }