/// <summary> /// 从Json字符串反序列化出JObject /// </summary> public static JObject DeserializeToObject(string json) { JValue jValue = JParser.Parse(json); if (null != jValue) { if (ValueType.OBJECT == jValue.ValueType) { return(jValue.Value as JObject); } } return(null); }
/// <summary> /// 从Json字符串反序列化出JArray /// </summary> public static JArray DeserializeToArray(string json) { JValue jValue = JParser.Parse(json); if (null != jValue) { if (ValueType.ARRAY == jValue.ValueType) { return(jValue.Value as JArray); } } return(null); }
/// <summary> /// 从Json字符串反序列化 /// </summary> public static T Deserialize <T>(string json) { if (typeof(T) == typeof(string)) { throw new Exception("T 类型为String"); } JValue jValue = JParser.Parse(json); if (null == jValue) { return(default(T)); } return((T)jValue.ToDeserialize(typeof(T))); }