C#json Data types

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.