JavaScript handles JSON-formatted data

Source: Internet
Author: User

JSON, a JavaScript object tag, is a lightweight data interchange format that is ideal for server-to-javascript interaction. JSON is a data format that is based on plain text.

JSON is the native format of JavaScript, and you can use JSON to transfer a simple string, number, Boolean, array, complex object.

When JSON represents an array, use [] contains all elements, each element is separated by commas, and the object object uses {} In JSON to contain a series of unordered Key-value key-value pairs, and value can also represent an object or an array.

JavaScript can use "." Directly when accessing JSON data. operator to access the properties of the JSON data, or assign a value to the property directly using "=".

JSON Data Structure transformation

Json2.js is a JS source file for converting JSON data structures to and from strings

1. Use the Stringify () method to string the JSON object

2. Use the parse () method to convert a JSON-formatted string into a JSON data object

3. Use the eval () method to convert a normal string to a JSON data object. Converting a JSON object to a string can be used anywhere else after the converted text string

JavaScript handles JSON-formatted data

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.