imported>Bbon (새 문서: =JSON= ===사이트 링크=== * [http://jsonlint.com/ json Validator] * [https://json.codeplex.com/ Json.Net] <syntaxhighlight lang="csharp" title="Json.Net Sample Code">using Syste...) |
(차이 없음)
|
2014년 10월 1일 (수) 01:21 판
JSON
사이트 링크
<syntaxhighlight lang="csharp" title="Json.Net Sample Code">using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.Services; using System.Data.SqlClient; using Newtonsoft.Json; using System.Data; using System.Web.Script.Services;
public partial class Serialization : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) { SelectMethod(); } [WebMethod] public static string SelectMethod() { SqlConnection con = new SqlConnection("Data Source=.; Initial Catalog=TestDB; User ID=sa; Password=Micr0s0ft"); { SqlCommand cmd = new SqlCommand("select * from TestTable", con); { SqlDataAdapter sqlDa = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); sqlDa.Fill(dt); string test = JsonConvert.SerializeObject(dt); // Serialization //JsonConvert.DeserializeObject(test); DataTable dtt = (DataTable)JsonConvert.DeserializeObject(test, dt.GetType()); return test; } } }
}</syntaxhighlight}