JSON syntax-A simple definition of an object

Source: Internet
Author: User



JSON (JavaScript Object Notation) is a lightweight data interchange format. It is based on a subset of ECMAScript. JSON takes a completely language-independent text format, but also uses a similar idiom to the C language family (c, C + +, C #, Java, JavaScript, Perl, Python, and so on). These features make JSON an ideal data exchange language. Easy to read and write, but also easy to machine parse and generate (network transfer speed).
It's an official definition, I can't read it. I'm just interested in the origin of JSON.
Anyway, JSON syntax rules:
Data in key-value pairs
Data is separated by commas
Curly braces Save Object
Square brackets Save Array

The writing format for JSON data is: Name: Value (name:value).

Name/value pairs are written in front (in double quotes), and value pairs are written in the following (same

In double quotes), separated by a colon in the middle:

"FirstName": "John"

This is easy to understand and is equivalent to this JAVASCRIPT statement:

Firstname= "John"

Specific format:
1, the object is an unordered "' name/value ' Pair" collection.
(1) An object starts with "{" (opening parenthesis) and "}" (closing parenthesis) ends.
(2) Each "name" followed by a ":" (colon);
(3) "' Name/value ' pair" is separated by "," (comma).
2, an array is an ordered set of values (value).
(1) An array begins with "[" (the left square bracket), and "]" (the right square bracket) ends.
(2) Use "," (comma) to separate values.
What is the specific JSON, personally think is to set the object to look good, well

A little bit easier to understand, see the code:

Summing up, with JSON syntax can be a simple assignment of custom objects, through the form of key-value pairs, easy to understand, the code is short, but the rules are determined, not easy to expand. In the actual application, according to different needs to use it.


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

JSON syntax-A simple definition of an 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.