How to convert a dataset to Josn and output, this is a problem for many novice friends, and here's a good example to help you.
The code is as follows: public class jsonutil { public string Tojson (DataSet DataSet) { String jsonstring = "{"; &nb Sp foreach (DataTable table in dataset.tables) { jsonstring = "" "+ table. TableName + "": "+ tojson (table) +", "; } jsonstring = Jsonstring.trimend (', '); return jsonstring +"} " ; } public string Tojson (DataTable dt) { StringBuilder jsonstring = new StringBuilder (); Nstring.append ("["); datarowcollection DRC = dt. rows; for (int i = 0; i < DRC. Count; i++) { jsonstring.append ("{"); for (int j = 0; J < dt. Columns.count; J + +) { string strkey = dt. COLUMNS[J]. columnname; string strvalue = Drc[i][j]. ToString (); Type type = dt. COLUMNS[J]. datatype; jsonstring.append ("" "+ Strkey +" ":"); strvalue = String.Format (strvalue, type); JS Onstring.append ("" "" + strvalue + "" ","); } jsonstring.append ("},");nbsp } Jsonstring.remove (jsonstring.length-1, 1); jsonstring.append ("]"); return jsonstring.tostring () ; } } use code as follows: Jsonutil ju = new Jsonutil (); Response.Write (ju. Tojson (DS)); If there is a problem parsing, you can replace the "" "" "in the Code with" ""