A new method of Html5--json

Source: Internet
Author: User

JSON (JavaScript object Notation, JS tag) is a lightweight data interchange format. It is based on a subset of ECMAScript (the JS specification developed by the consortium) that stores and represents data in a text format that is completely independent of the programming language. The simplicity and clarity of the hierarchy makes JSON an ideal data exchange language. Easy for people to read and write, but also easy to machine analysis and generation, and effectively improve the network transmission efficiency.

The JSON key-value pair is a way to save the JS object, and the JS object is written in a similar manner, the key/value pairs in the combination of the key names in front and double quotation marks "" package, using a colon: delimited, and then the value:
1 {"firstName": "John"}
This is easy to understand and is equivalent to this JAVASCRIPT statement:
1 {firstName = "John"}
The relationship between JSON and JS object Many people do not know the relationship between JSON and JS objects, and even who is not clear. In fact, it can be understood that JSON is a string representation of a JS object, which uses text to represent the information of a JS object, essentially a string. Such as
1 varobj = {a: ‘Hello‘, b: ‘World‘}; //这是一个对象,注意键名也是可以使用引号包裹的
1 varjson = ‘{"a": "Hello", "b": "World"}‘//这是一个 JSON 字符串,本质是一个字符串

JSON as a user data transmission of things, in today's web front-end development in the use of a lot, but when it is used, developers need to pay attention to a problem is how the JSON object to parse into a JS statement.

Previously, any JSON-type object could be parsed into a JS statement using the eval () method.

After HTML5 presented, there were two other methods, Stringify () and Parse (), which were specifically parsed into the JS statement for the JSON object.

There is a purpose, particularly practical, copy of the object:

With this method, the object copy can be implemented, and there is no connection between the two objects at all.

A new method of Html5--json

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.