在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
object To json public static string ObjectToJson(object obj) { JsonSerializerSettings jss = new JsonSerializerSettings(); IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss";//日期转化为字符串类型 jss.ContractResolver = new LowercaseContractResolver();//Column转化为小写 jss.Converters.Add(timeConverter); return JsonConvert.SerializeObject(obj, Newtonsoft.Json.Formatting.Indented, jss); } json To object public static object JsonToObject(string jsonString, object obj) { return JsonConvert.DeserializeObject(jsonString, obj.GetType()); }
|
请发表评论