Newtonsoft.Json对object进行json转化(时间格式的处理)

前端之家收集整理的这篇文章主要介绍了Newtonsoft.Json对object进行json转化(时间格式的处理)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

/// <summary>
/// object转化为json时Datetime类型格式转化
/// </summary>
/// <returns></returns>
private static IsoDateTimeConverter SetJsonDateTimeFormate()
{
IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm";
return timeConverter;
}

//将object转化成json格式

private string GetConvertEntityJson(string id) { string json = ""; BPileinfo bllPileinfo = new BPileinfo(); MES_YD_PILEINFO pileInfo = bllPileinfo.GetPileinfoInfo(id); json = JsonConvert.SerializeObject(pileInfo,SetJsonDateTimeFormate()); return json; }

原文链接:https://www.f2er.com/json/290598.html

猜你在找的Json相关文章