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}