public T Parse(string body, string charset) { T val = null; IDictionary dictionary = JsonConvert.Import(body) as IDictionary; if (dictionary != null) { IDictionary dictionary2 = null; foreach (object key in dictionary.Keys) { dictionary2 = (dictionary[key] as IDictionary); if (dictionary2 != null && dictionary2.Count > 0) { break; } } if (dictionary2 != null) { IAopReader reader = new AopJsonReader(dictionary2); val = (T)AopJsonConvert(reader, typeof(T)); } } if (val == null) { val = Activator.CreateInstance <T>(); } if (val != null) { val.Body = body; } return(val); }
public T Parse(string body, string charset) { T rsp = null; IDictionary json; try { json = JsonConvert.DeserializeObject <IDictionary>(body); } catch (Exception) { json = null; } if (json != null) { JObject data = null; // 忽略根节点的名称 foreach (object key in json.Keys) { data = json[key] as JObject; if (data != null && data.Count > 0) { break; } } if (data != null) { IAopReader reader = new AopJsonReader(data); rsp = (T)AopJsonConvert(reader, typeof(T)); } } if (rsp == null) { rsp = Activator.CreateInstance <T>(); } if (rsp != null) { rsp.Body = body; } return(rsp); }
public T Parse(string body, string charset) { T rsp = null; IDictionary json = JsonConvert.Import(body) as IDictionary; if (json != null) { IDictionary data = null; // 忽略根节点的名称 foreach (object key in json.Keys) { data = json[key] as IDictionary; if (data != null && data.Count > 0) { break; } } if (data != null) { IAopReader reader = new AopJsonReader(data); rsp = (T)AopJsonConvert(reader, typeof(T)); } } if (rsp == null) { rsp = Activator.CreateInstance <T>(); } if (rsp != null) { rsp.Body = body; } return(rsp); }