DataSet转化为JSON C#

DataEntity.sys.sbw_articleEty ety;
   Business.sys.sbw_articleBN bn = new Business.sys.sbw_articleBN();
   ety = bn.GetRealEtyBySplitProcedure(null, 1, 2);

   System.Web.Script.Serialization.JavaScriptSerializer serial = new System.Web.Script.Serialization.JavaScriptSerializer();
   
   serial.RegisterConverters(new System.Web.Script.Serialization.JavaScriptConverter[] { new Microsoft.Web.Preview.Script.Serialization.Converters.DataSetConverter(), new Microsoft.Web.Preview.Script.Serialization.Converters.DataTableConverter(), new Microsoft.Web.Preview.Script.Serialization.Converters.DataRowConverter() });
   string jsonStr = serial.Serialize(ety);
   /*
   
{"tables":[{"columns":[ {"name":"aid","dataType":"String","defaultValue":null,"readOnly":false,"isKey":false},
      {"name":"article_name","dataType":"String","defaultValue":null,"readOnly":false,"isKey":false},
      {"name":"segregate_id","dataType":"String","defaultValue":null,"readOnly":false,"isKey":false},
      {"name":"price","dataType":"Object","defaultValue":null,"readOnly":false,"isKey":false},
      {"name":"image_url","dataType":"String","defaultValue":null,"readOnly":false,"isKey":false},
      {"name":"detail","dataType":"String","defaultValue":null,"readOnly":false,"isKey":false},
      {"name":"rowstat","dataType":"Number","defaultValue":null,"readOnly":false,"isKey":false}
     ],
   "rows":[{"aid":"00000001","article_name":"测试商品","segregate_id":"002","price":1.00,"image_url":"aa.jpg","detail":"","rowstat":null},
     {"aid":"00000002","article_name":"测试商品2","segregate_id":"002","price":10.00,"image_url":"aa.jpg","detail":"","rowstat":null}
     ]
   },
   {"columns":[{"name":"RECORDCOUNT","dataType":"Number","defaultValue":null,"readOnly":false,"isKey":false},
      {"name":"PAGECOUNT","dataType":"Number","defaultValue":null,"readOnly":false,"isKey":false},
      {"name":"CURRENTPAGE","dataType":"Number","defaultValue":null,"readOnly":false,"isKey":false},
      {"name":"PAGESIZE","dataType":"Number","defaultValue":null,"readOnly":false,"isKey":false}],
       "rows":[{"RECORDCOUNT":15,"PAGECOUNT":8,"CURRENTPAGE":1,"PAGESIZE":2}]
   }
  ]
}
    * */

你可能感兴趣的:(json)