Impact of JSON upgrade

Source: Internet
Author: User
No version is set for the Code officially provided by JSON. Therefore, the latest version of the code is used as a difference. 1. Versions earlier than JSON. v2008.04.25 are earlier than JSON. v2008.04.25 (including v2008.04.25). When converting an object instance, The jsonobject uses the getmethods () method. Getmethods () is used to obtain the classes currently converted to JSON and the Methods declared in all parent classes of this class. Here, there is a getclass () method in Java. Lang. object to obtain the full name of the current class. This method is executed during the conversion process. Therefore, in the converted JSON data, in addition to necessary attributes, a value pair whose class is the primary key is also included. For example, for a class named org. teamlet. ws. Business class named Department, a value pair is generated in JSON data after JSON conversion. The primary key (key) is class; the value is the full name of the current class: Org. teamlet. WS. business. department has both advantages and disadvantages. The advantage is that the server does not need to make any settings, and the corresponding class can be obtained from the JSON data to directly complete the conversion from JSON to Java. The problem is: first, the server information is exposed. Second, the Java client must use the same package name as the server. The original pure data conversion adds constraints. Third: for other languages (PHP, C/C ++, C #, and JavaScript are currently implemented), you need to set the value of this class. 2. For Versions later than JSON. v2008.06.25 and later than JSON. v2008.06.25 (including v2008.06.25), The jsonobject added a parameter: Boolean includesuperclass when converting the object instance. If the parameter is set to true, the effect is the same as that of JSON v2008.04.25. The getmethods () method is used. If the parameter is set to false, the getdeclaredmethods () method is used. This method obtains only the methods declared by the current class. Therefore, the parent class is Java. lang. the getclass () method in the object cannot be obtained. In the converted JSON data, there is no value pair with class as the primary key mentioned above. In this way, it brings great flexibility to the client. The client can construct any class containing business attributes without worrying about the package name of the class. These package names are useless for PHP and JavaScript. But at the same time, there is a problem. How can I convert the server to the corresponding business needs instance? 3. Differences from JSON-lib is an open-source tool developed based on JSON format, which is totally different from the official JSON open-source tool. In JSON-lib, the latter type of JSON conversion is used. The getdeclaredmethods () method is used, and class value pairs are not included in JSON data. (In addition, there are other differences that deviate from the topic and will not be detailed.) using JSON-Lib for data transmission requires some configuration work on the server based on the business. 4. The impact on applications restlet uses earlier versions of JSON, And the WebService component is also affected. Fortunately, the WebService component supports both JSON and JSON-lib, and compatibility is not difficult. It only has a great impact on client changes, especially for systems that are already deployed and will be used soon. After the JSON upgrade, the transmission and conversion performance will not change much. The server is changed to a unified conversion form, and the plug-and-play and zero-configuration features are lost.

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.