/// <summary> /// 将参数值序列化为json文本 /// </summary> /// <param name="obj">对象</param> /// <param name="encoding">编码</param> /// <returns></returns> public string Serialize(object obj, Encoding encoding) { if (obj == null) { return(null); } var dateTimeFormate = "yyyy-MM-dd HH:mm:ss"; #if NET45 if (JsonNet.IsSupported == true) { return(JsonNet.SerializeObject(obj)); } return(JSON.Serialize(obj, dateTimeFormate)); #endif #if NETCOREAPP2_0 var setting = new JsonSerializerSettings { DateFormatString = dateTimeFormate }; return(JsonConvert.SerializeObject(obj, setting)); #endif }