对象转JSON字符串
/// <summary> /// 对象转Json字符串 /// </summary> /// <param name="obj"></param> /// <param name="isCamel"></param> /// <returns></returns> public static string ToJsonString(object obj, bool isCamel = false) { var settings = new JsonSerializerSettings { DateFormatString = "yyyy-MM-dd HH:mm:ss", ReferenceLoopHandling = ReferenceLoopHandling.Ignore }; if (isCamel) { settings.ContractResolver = new CamelCasePropertyNamesContractResolver(); } return JsonConvert.SerializeObject(obj, settings); }