if you asp.net with c# behindcode you can use sqldatasource on aspx and on codebehind write this code:
protected void Page_Load(object sender, EventArgs e)
{
DataView dv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
DataTable dt = dv.ToTable();
System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
List<dictionary><string,>> rows = new List<dictionary><string,>>();
Dictionary<string,> row;
foreach (DataRow dr in dt.Rows)
{
row = new Dictionary<string,>();
foreach (DataColumn col in dt.Columns)
{
row.Add(col.ColumnName, dr[col]);
}
rows.Add(row);
}
string data = serializer.Serialize(rows);
string script= String.Format("<script type=\"text/javascript\">var jsondata = {0}</script>",data);
if (!this.ClientScript.IsClientScriptBlockRegistered("datascript"))
{
this.ClientScript.RegisterClientScriptBlock(this.GetType(), "datascript", script);
}
}
}
Don't forget to add register script block on aspx page.