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

        ///


        /// object转化为json时Datetime类型格式转化
        ///

        ///
        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;
        }

你可能感兴趣的:(jQuery,.NET)