Class library file referencing the corresponding framework: http://json.codeplex.com/
In the general handler Axhx:
Referenced namespaces:
Using System.IO;
Using Newtonsoft.json;
using(Db2datacontext con =NewDb2datacontext ()) {List<people> PL =con.people.ToList (); Jsonserializer Serializer=NewJsonserializer (); StringWriter SW=NewStringWriter (); Serializer. Serialize (NewJsonTextWriter (SW), PL); stringresult =SW. Getstringbuilder (). ToString (); //context. Response.Write ("{\" msg\ ": \" \ ", \" data\ ": \" "+ result +" \ "}");context. Response.Write (Result); Context. Response.End (); }
Also a partial class:
Outside the class:
[Jsonobject (Memberserialization.optin)]
Before each property:
[Jsonproperty]
This allows the data to have content such as:
[Jsonobject (memberserialization.optin)] Public Partial classpeople{[Jsonproperty] Public stringnames {Get { return This. _name; }} [Jsonproperty] Public stringBirthdays {Get { return This. _birthday. Value.tostring ("yyyy mm month DD Day"); }} [Jsonproperty] Public stringSexs {Get { return This. _sex. Value?"male":"female"; } }}
C#json Data types