Newtonsoft.json Basic Usage

Source: Internet
Author: User

Newtonsoft.json is a Json format processing class library for. NET open source

Official website: http://json.codeplex.com/

The Newtonsoft.json library is referenced in the project being used. Commonly used methods have serialization and deserialization methods

1 Serialization: Serializing an object into a JSON-formatted string

V_bbstopic_user entity = db. gettentity<v_bbstopic_user>(SQL);             if NULL             {                string json = jsonconvert.serializeobject (entity);  Serializes the                context. Response.Write (JSON);            }

2 deserialization: Converts a string of josn format into an entity object. For example

 Public class A    {        publicstringgetset;}          Public Get Set ; }    } Deserialization string json="{' ID ': ' 1 ', ' createdate ': ' 2014-08-20 '}"  = jsonconvert.deserializeobject< a> (JSON);

3 Newtonsoft.json Other methods

// JSON cannot be an array string " {' A ': ' AAA ', ' B ': ' BBB ', ' C ': ' CCC '} "  = jobject.parse (JSONTEXT2); Console.WriteLine ("A:"+jobj["a"]); Console.read ();

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.