我使用JSON.NET創建了JSON字符串。使用在JavaScript中使用JSON字符串
下面的代碼
public void JSONTable()
{
StringBuilder str = new StringBuilder();
SqlConnection con = new SqlConnection("Data Source=INBDQ2WK2LBCD2S\\SQLEXPRESS;Initial Catalog=MCAS;Integrated Security=SSPI");
SqlDataAdapter adp = new SqlDataAdapter("select top 10 x,dt from test4 order by Id desc", con);
DataTable dt = new DataTable();
adp.Fill(dt);
string DATA = JsonConvert.SerializeObject(dt, new Newtonsoft.Json.Formatting());
}
的JSON看起來像
[{"x":"0","dt":"11/21/2013 3:07:53 PM"},{"x":"0","dt":"11/21/2013 3:07:52 PM"},{"x":"0","dt":"11/21/2013 3:07:50 PM"},{"x":"0","dt":"11/21/2013 2:47:21 PM"},{"x":"0","dt":"11/21/2013 2:47:20 PM"},{"x":"0","dt":"11/21/2013 2:20:02 PM"},{"x":"188","dt":"11/20/2013 11:46:53 AM"},{"x":"188","dt":"11/13/2013 11:31:38 AM"},{"x":"188","dt":"11/13/2013 11:31:26 AM"},{"x":"188","dt":"10/31/2013 2:49:27 PM"}]
現在我該如何使用這個JSON字符串DATA
爲JavaScript?
如何創建.json
擴展名的物理文件?
你想在哪裏以及如何使用這些數據? –
那麼我想用它來創建谷歌圖表或者高圖。 – SPandya
– Enam