JSON string converted to object, object converted to JSON string

Source: Internet
Author: User

Method One:

Assembly: System.Web.Extensions;

namespaces: System.Web.Script.Serialization;

The most important class: JavaScriptSerializer

Instantiation of

JavaScriptSerializer js = new JavaScriptSerializer ();


Js. Serialize ();//Convert object to JSON string; serial number

Js. Deserialize ();//convert JSON strings to objects; deserialize

Method Two:

Assembly: Newtonsoft.Json.dll;

namespaces: Newtonsoft.json;

Important classes: JsonConvert; 4.0 version and above

Jsonconvert.serializeobject ();

Jsonconvert.deserializeobject ();

Important classes: javascriptconvert;4.0 the following versions

Javascriptconvert.serializeobject ();

Javascriptconvert.deserializeobject ();

Method Three:

Assembly: Newtonsoft.Json.Compact.dll;

namespaces: Newtonsoft.json; Version 4.0 and above

Important classes: jsonconvert;4.0 the following versions

Jsonconvert.serializeobject ();

Jsonconvert.deserializeobject ();

Small warning: Javascriptconvert.serializeobject is present in the 1.3.X version


If the new version of Json.NET, such as Json.NET 4.0, has been moved under the Newtonsoft.Json.JsonConvert class.


Newtonsoft.Json.JsonConvert.DeserializeObject


Newtonsoft.Json.JsonConvert.SerializeObject


So if you can't find the Javascriptconvert class, it's your version of the problem, please try to download other versions of json.net;

JSON transformation xml:

Assembly: System.Runtime.Serialization.dll;

namespaces: System.Runtime.Serialization.Json;

Important classes: DataContractJsonSerializer;

Important class: Xmlobjectserializer//provides a base class for serializing an object into an XML stream or document

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.