About NET3.5 JSON operations

Source: Internet
Author: User

Share an article on the NET3.5 JSON operation method. For more information, see.

A few days ago, I upgraded the class library from Net2.0 to 3.5. The process was still quite smooth, but one of the DLL encountered some problems, and Newtonsoft. json. DLL. Originally, it has two versions. One is based on the Net2.0 class library and the other is based on the Net3.5 class library. Is there any version based on 4.0 currently? It is unclear. this DLL reference may fail because the code is not standard.

After finding the corresponding 3.5 version of DLL overwrite, it seems that the compilation is normal. however, when converting the JSON format, the system prompts that the conversion failed. After calling and tracking, the difference between 2.0 and 3.5 is still syntactically different. I searched the blog for a circle, I found that there are indeed a lot of materials, but they are all complicated. Some only talk about a certain point. taking advantage of the weekend time, we sorted out the 3.5-based JSON operation, which is now published for future use. JSON operation scenarios, including the Web client and server, Newtonsoft. json is used on the server, and I use json on the client. js file. This file is also open-source and available in my package. You can download it directly. these two class libraries are used together to parse JSON. the supported data class libraries are described below. Currently, the type shown in-1 is supported. of course, other data types can also be supported. You can expand it on your own, but the following data is enough for me. figure-1 OK. Next we need to operate JSON based on these data types. It should be said that the NET3.5 version is simpler than 2.0, and it also supports the Linq language. the entire parsing process is still relatively smooth, as long as you pay attention to the following classes. how to use it has been explained in the source code provided. newsonsoft. json. linq. JObjectNewsonsoft. json. linq. JPropertyNewsonsoft. json. linq. JArrayNewsonsoft. json. linq. JValue needs to be described here, that is, we plan to generate a JSON string in the foreground and generate a able object directly in the background. This function can be implemented. in the preceding JsonDataType enumeration, ClientDataTable is of this type. in short, it is composed of the Array + Object of the client, that is, the Array [0] = Object mode, so that we can directly generate a DataTable during background parsing. of course, we can define more than this format, and parse the format by ourselves. Finally, let's take a look at the example. The example based on the above data type is shown in-2. the example can be run directly.

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.