JSON (JavaScript Object Notation)

Source: Internet
Author: User

What is JSON:is a data interchange format that can replace XML    JSON syntax rules:in the JS language, everything is an object. Therefore, any supported type can be represented by JSON, such as strings, numbers, objects, arrays, and so on. However, objects and arrays are two of the more special and common types:      1. The object is represented as a key-value pair of 2. The data is separated by commas by 3. Curly braces Save Object 4. Square brackets Save ArrayJSON key/value pairs:The JSON key-value pair is a way to save the JS object, and the syntax of the JS object is similar, the key/value pairs in the combination of key names are written in front and double quotation marks "" package, using a colon: delimited, and then immediately after the valuethe relationship between JSON and JS objects:   JSON is a string representation of a JS object, which uses text to represent the information of a JS object, essentially a stringJSON and JS objects are transferred to each other:     To implement a conversion from an object to a JSON string, use the Json.stringify () method:
1 varjson = JSON.stringify({a: ‘Hello‘, b: ‘World‘}); //结果是 ‘{"a": "Hello", "b": "World"}‘
To implement a conversion from JSON to an object, use the Json.parse () method:
1 varobj = JSON.parse(‘{"a": "Hello", "b": "World"}‘); //结果是 {a: ‘Hello‘, b: ‘World‘}
Common types:    In the JS language, everything is an object. Therefore, any supported type can be represented by JSON, such as strings, numbers, objects, arrays, and so on.     However, objects and arrays are two of the more special and common types. Object: Object in JS is the contents of the curly brace wrapped {}, the data structure is {key1:value1, key2:value2, ...} key-value pair structure. In an object-oriented language, key is the property of the object, and value is the corresponding values. Key names can be represented using integers and strings.     The type of the value can be any type. Array: The array in JS is square brackets [] wrapped content, data structure for ["Java", "JavaScript", "VB", ...] index structure. In JS, an array is a special type of data, and it can also use key-value pairs like objects, but it is still much used by indexes. Similarly, the type of the value can be any type.  

JSON (JavaScript Object Notation)

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.