The literal representation of a json--object

Source: Internet
Author: User

JSON is a special representation of the literal of JS, which uses text to represent JS object information, which is essentially a string

var // This is an object, note that the key name can also be wrapped in quotation marks var // This is a JSON string, which is essentially a string

To convert from a JS object to a JSON string, use the Json.stringify () method:

var // The result is ' {' A ': ' Hello ', ' B ': ' World '} '

To implement a conversion from JSON to a JS object, use the Json.parse () method:

var // The result is {a: ' Hello ', B: ' World '}

Storing JSON in array form:

<script>    var person = [        "FirstName": "Brett", "LastName": "McLaughlin" },        "FirstName": "Jason", "LastName": "Hunter" }    ];    Console.log (person[0].firstname); // Brett</script>

The literal representation of a json--object

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.