/// <summary> /// 数组对象转为JArray /// </summary> /// <param name="obj"></param> /// <returns></returns> public static JArray ObjectToJArray(Object obj) { if (obj == null) { return((JArray)JsonConvert.DeserializeObject("[]")); } else { return((JArray)JsonConvert.DeserializeObject(Lw_Utils.ObjectToJsonStr(obj))); } }
/// <summary> /// 对象转为json 必须传入的是单个实体类 /// </summary> /// <param name="obj"></param> /// <returns></returns> public static JObject ObjectToJson(Object obj) { if (obj == null) { return((JObject)JsonConvert.DeserializeObject("{}")); } else { return((JObject)JsonConvert.DeserializeObject(Lw_Utils.ObjectToJsonStr(obj))); } }