妈妈再也不用为我转Json而担忧了!!

很简单,没什么好说明的,嗯!

public class ShowTablePage<T> where T : class, new()
{
public int total { get; set; }
public List<T> rows { get; set; }
}
public class ShowTablePage
{
public int total { get; set; }
public DataTable rows { get; set; }
}
public class ShowCombobox
{
public int id { get; set; }
public string text { get; set; } public string group { get; set; }
public bool selected { get; set; } public List<ShowCombobox> children { get; set; }
} public class ResultMessage<T>
{
public ResultMessage()
{ }
public int Code { get; set; }
public T Msg { get; set; }
}

  

 protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ToJsonGetData tjgd = new ToJsonGetData();
DataTable dt = tjgd.GetData1();
ShowTablePage stp = new ShowTablePage { total = dt.Rows.Count, rows = dt };
var obj = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.Linq.JToken.FromObject(stp);
string json = obj.ToString(); List<ToJsonENTITY> listEn = tjgd.GetData2();
ShowTablePage<ToJsonENTITY> stp2 = new ShowTablePage<ToJsonENTITY> { total = listEn.Count, rows = listEn };
obj = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.Linq.JToken.FromObject(stp2);
json = obj.ToString(); Response.Write(json);
}
}

下载:Json.dll.7z

屌丝技能--转Json(Newtonsoft.Json.dll)的更多相关文章

  1. C# 解析json Newtonsoft.Json

    Newtonsoft.Json.dll public class ErrorInfo { public error_response error_response { get; set; } } pu ...

  2. [C#][Newtonsoft.Json] Newtonsoft.Json 序列化时的一些其它用法

    Newtonsoft.Json 序列化时的一些其它用法 在进行序列化时我们一般会选择使用匿名类型 new { },或者添加一个新类(包含想输出的所有字段).但不可避免的会出现以下情形:如属性值隐藏(敏 ...

  3. 【转】C#解析Json Newtonsoft.Json

    Newtonsoft.Json源码 Newtonsoft.Json介绍 在做开发的时候,很多数据交换都是以json格式传输的.而使用Json的时候,我们很多时候会涉及到几个序列化对象的使用:DataC ...

  4. .Net使用Newtonsoft.Json.dll(JSON.NET)对象序列化成json、反序列化json示例教程

    JSON作为一种轻量级的数据交换格式,简单灵活,被很多系统用来数据交互,作为一名.NET开发人员,JSON.NET无疑是最好的序列化框架,支持XML和JSON序列化,高性能,免费开源,支持LINQ查询 ...

  5. 使用Newtonsoft.Json.dll(JSON.NET)动态解析JSON、.net 的json的序列化与反序列化(一)

    在开发中,我非常喜欢动态语言和匿名对象带来的方便,JSON.NET具有动态序列化和反序列化任意JSON内容的能力,不必将它映射到具体的强类型对象,它可以处理不确定的类型(集合.字典.动态对象和匿名对象 ...

  6. 更新Newtonsoft.Json后报异常,未能加载文件或程序集“Newtonsoft.Json

    未能加载文件或程序集“Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed”或它的某一个 ...

  7. C# 解析 json Newtonsoft果然强大,代码写的真好

    C# 解析 json JSON(全称为JavaScript Object Notation) 是一种轻量级的数据交换格式.它是基于JavaScript语法标准的一个子集. JSON采用完全独立于语言的 ...

  8. Newtonsoft.Json code

    序列化 Product product = new Product(); product.ExpiryDate = new DateTime(2008, 12, 28); JsonSerializer ...

  9. Newtonsoft.Json 把对象转换成json字符串

    var resultJson = new { records = rowCount, page = pageindex, //总页数=(总页数+页大小-1)/页大小 total = (rowCount ...

随机推荐

  1. ios 网络/本地播放器

    推荐播放器: LRLAVPlayer相对易懂好修改,调整添加内容. https://github.com/codeWorm2015/videoPlayer NSString*path=[[NSBund ...

  2. nodeName,nodeValue,nodeType,typeof 的区别

        nodeName 属性含有某个节点的名称.  元素节点的 nodeName 是标签名称  属性节点的 nodeName 是属性名称  文本节点的 nodeName 永远是 #text  文档节 ...

  3. [.NET] 《C# 高效编程》(一) - C# 语言习惯

    C# 语言习惯 目录 一.使用属性而不是可访问的数据成员 二.使用运行时常量(readonly)而不是编译时常量(const) 三.推荐使用 is 或 as 操作符而不是强制类型转换 四.使用 Con ...

  4. Eclipse导入Android签名

    本篇主要参照http://blog.csdn.net/wuxy_shenzhen/article/details/20946839 在安装安卓apk时经常会出现类似INSTALL_FAILED_SHA ...

  5. LeetCode 207. Course Schedule(拓扑排序)

    题目 There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may have p ...

  6. C语言学习的第一章

    首先,学习编写程序要先知道什么是程序,我们为什么要写程序? 程序就是为了让计算机执行某些操作或解决某个问题而编写的一系列有序指令的集合.程序里有很多算法,算法是解决问题的具体方法和步骤,就像我们想要得 ...

  7. 略过 Mysql 5.7的密码策略

    之前从mysql 5.6的时候,mysql 还没有密码策略这个东东,所以我们每个用户的密码都可以随心所欲地设置,什么123 ,abc 这些,甚至你搞个空格,那也是OK的. 而mysql.user 表里 ...

  8. python-day2 字典

    ===========字典功能=============> dict.clear() -->清空字典 dict.keys() -->获取所有key dict.values() --& ...

  9. document.all 用法

    一. document.all是页面内所有元素的一个集合.例如:        document.all(0)表示页面内第一个元素 二. document.all可以判断浏览器是否是IE     if ...

  10. 荣获MVP感想

    感言 最近特别忙,除了工作之外最开心的算是收到了MVP的奖杯,从到申请到审批通过也不过一个礼拜的时间,从去年就开始想着是否应该一试,通过和张善友大哥的沟通抱着试一试的忐忑结果意外惊喜通过了,由于每月申 ...