Why do json attribute names use double quotation marks (I guess) and json double quotation marks?

Source: Internet
Author: User

Why do json attribute names use double quotation marks (I guess) and json double quotation marks?

Cause 1:

More standardized for analysis

Cause 2:

Avoid incompatibility problems caused by keywords such as class

Cause 3:

It may also be the most obscure:

Var a = 00; var B = {00: 12}; a in B; --> truevar a = 0; var B = {'00': 12}; a in B; --> false

I guess that if the property name of a js object is not of the string type, type conversion is performed first, but unexpected values may appear in this process. Although this is only an example, but it is necessary to develop a good habit.


Json Object Attributes must be enclosed in double quotation marks

Not mandatory. As long as the attribute name complies with the naming rules of the variable, double quotation marks can be added.

What should I do if the json value contains double quotation marks?

Replace "\" ""

Related Article

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.