首先需要引用Newtonsoft.Json
using Newtonsoft.Json;using Newtonsoft.Json.Serialization;然后转换对象
Model.JsonResult jsonResult = new Model.JsonResult{ State = 200, Message = "success", Data = dt.ToList()};string json = JsonConvert.Serialize ( jsonResult, Formatting.Indented, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() });输出的JSON字符串
{ "message": "success", "state": 200, "data": [], " ": ""} 继续阅读与本文标签相同的文章
-
Postgresql的XLOG累积源码分析
2026-05-22栏目: 教程
-
Chromium Viz 浅析 - SkiaRenderer & SkiaOutputSurface
2026-05-22栏目: 教程
-
Palo Alto Networks(派拓网络)如何为云安全保驾护航?
2026-05-22栏目: 教程
-
服务限流算法的几种实现
2026-05-22栏目: 教程
-
关于Ahead-of-Time Compilation的调研与总结
2026-05-22栏目: 教程
