In-depth analysis of problems related to the JSON format

Source: Internet
Author: User

When you enter new vehicle data, you create a new element in the array object. No clumsy string operations are required. After a user inputs all the vehicle data, you only need to construct a JSON string from the object and send the string to the server by storing it in a hidden field. This method is much better than the first method.

At present, the problem between multi-group attributes and multi-value attributes is that data must be input to the same input field. That means you must save the data of the first vehicle before entering the data of the second vehicle. You can solve this problem in two ways:

Send the data of the first vehicle to the server and clear the input fields to allow the user to enter the data of the next vehicle. Data is cached to the client in JSON format and input fields are cleared to allow users to enter data of the next vehicle. The first method has the problem that the server needs to be accessed every time the data of a vehicle is input.

  • Explain the rich and colorful JSON data
  • How to Use the JSON Conversion Tool for detailed analysis
  • Detailed JavaScript code Display in JSON Sequence
  • Describes in detail the conversion of JSON serialization.
  • The author provides detailed instructions on the Json getting started document.

This is not very good; if you have to wait for the server to respond after entering the vehicle data, the user will feel very disappointed. In another method, the response time of the second method is almost zero. Users can quickly enter all vehicle data without waiting. However, you need to consider how to store data on the client. There are more ways to store data on the client:

When you click to add data for the next vehicle, the data is cached to a hidden table field in some form. Cache data to a JavaScript Object. If you want to store data in hidden fields, you will be worried about processing many hidden fields or processing hidden field data each time you enter new vehicle data. This is just like string operations that require frequent string processing.

However, the second method for caching data provides an object-oriented method for caching. When you enter new vehicle data, you create a new element in the array object. No clumsy string operations are required. After a user inputs all the vehicle data, you only need to construct a JSON format from the object and send the string to the server by storing it in a hidden field. This method is much better than the first method.

The function called when a user submits a page is actually used to verify the minimum number of occurrences. The biggest advantage of this method is that the screen does not need to be refreshed to input new vehicle data. Providing such static screens was once the main goal of Ajax technology, and now you can achieve this goal with JSON.

This is about updating the JSON format object and processing all the content of the html dom tree through JavaScript. The user response time is the minimum value because all operations are only executed on the client. You can use JSON to provide Ajax functions for applications.

When you click the Save button, the program calls another JavaScript function, which sets this JSON objectStringizedStore it in a hidden table field submitted to the server. JSON hasJSON.stringify()Function, which obtains the JavaScript Object as the input and returns the string output.

The server must be able to understand JSON strings and generate a server object to process and save data. The Web site http://www.json.org/java/index.html provides a Java API that handles most of the needs of Java-based applications.

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.