JSON (JavaScript Object Notation) is a lightweight data exchange format. Simply put, JSON can convert a set of data represented in a JavaScript object to a string, and then it can be easily passed between functions, alternatively, the string is transmitted from the Web Client to the server in an asynchronous application. This string looks a bit odd, but JavaScript can easily interpret it, And JSON can represent a more complex structure than "name/value pairs. For example, it can represent arrays and complex objects, not just a simple list of keys and values.
It has the following features:
1. Flexible JSON serializer for converting between. NET objects and JSON --
2. LINQ to JSON for manually reading and writing JSON -- LINQ to JSON for manual reading and writing of Json
3. High performance, faster than. NET's built-in JSON serializers -- High performance, faster than the built-in JSON serialization program of. NET
4. Writes indented, easy to read JSON -- shrink the writing to make Json readable
5. Convert JSON to and from XML -- supports conversion between JSON and XML formats
6. Supports. NET 2. NET 3.5. NET 4, Silverlight, Windows Phone and Windows 8 -- Support for. NET2.NET3.5. NET4, Silverlight, Windows Phone, and Windows 8
In. Net, the built-in object for reading and writing Json isDataContractJsonSerializerAndJavaScriptSerializerThese two. However, this is only supported after. Net 3.5. And the performance is not good.
The performance comparison diagram is as follows:
This is a comparison between the performance of the Json. Net 5 and. NET built-in objects, and now the Json. Net Version has reached Version 6.0.1, I believe it will have a better performance. JSON. NET is open-source: http://json.codeplex.com/, which contains the source code. For more information, see http://james.newtonking.com.
Of course, you can also download the Json. Net package by entering the Nuget management package through.
Next we will take a simple look at JSON. NET through the instance.
1. serialize an object as a json string.
2. deserialize the string into an object.
3. Conversion between JSON and XML.
4 ,...... Of course, there are other formats for conversion. We will not give an example for the moment. The subsequent articles will describe this in detail.
First define an object class Object
Email { ; Active { ; DateTime CreatedDate { ; IList<> Roles { ;
Instantiate the object class and serialize it to a Json string
Account account = = = = DateTime(, , , , , = List<>{, json = JsonConvert.SerializeObject(account, Formatting.Indented);
The result of the json string is
: : :
Continue to use the above Entity class
Now we define a Json string first. We can also modify the Json string generated above and then perform deserialization.
json = = JsonConvert.DeserializeObject<Account>(json);
The data obtained through debugging is
First, define a Json string and convert it.
json = = JsonConvert.DeserializeXNode(json, );
The conversion result is
Now, you need to define a simple XML string and then convert it.
xml = = json = JsonConvert.SerializeXmlNode(doc);
The result obtained through debugging is
1. Linq to JSON is used to operate JSON objects. It can be used to quickly query, modify, delete, and create JSON objects. When the content of a JSON object is complex and we only need a small part of the data, we can consider using Linq to JSON to read and modify part of the data instead of deserializing all.
2. Json. Net not only supports serialization and deserialization of objects, but also supports conversion between XML and JSON. It supports conversion between data types and JSON, such as DataSet, DataTable, Entity Framework and nhib.pdf, Collection, Dictionary, and Dynamic. Most data types are supported.
3. JSON. NET supports the serialization and deserialization of BSON data.
BSON (Binary Serialized Document Format) is a type of json Binary storage Format, Binary JSON for short. It is the same as JSON and supports embedded Document objects and array objects, however, BSON has some data types not available in JSON, such as Date and BinData.
4. JSON Schema is used to describe the structure and type of JSON data. Like the relationship between DTD and XML.
Now I know so many features. In short, it is very good for some configuration processing such as empty processing, Date Format control, and ignore attribute conversion, summary.
Tips for English
Get out of here. -- Click it.
None of your business. -- Close your ass.
I can't follow your step. -- I cannot keep up with your pace.
Author: aehyok
Source: http://www.cnblogs.com/aehyok/
Thank you for reading this article. If you are interested in the content described in my blog, please make a suggestion. Thank you for your support:-O.