Home > Web Front-end > JS Tutorial > JSON JavaScript simple example of processing JSON_javascript skills

JSON JavaScript simple example of processing JSON_javascript skills

WBOY
Release: 2016-05-16 17:39:55
Original
823 people have browsed it

JSON (JavaScript Object Notation) is a lightweight data exchange format. Easy for humans to read and write. It is also easy for machines to parse and generate. It is based on JavaScript Programming Language, a subset of Standard ECMA-262 3rd Edition - December 1999. JSON uses a completely language-independent text format, but also uses conventions similar to the C language family (including C, C, C#, Java, JavaScript, Perl, Python, etc.). These properties make JSON an ideal data exchange language.

JSON is constructed from two structures:

1. A collection of name/value pairs. In different languages, it is understood as an object, a record, a struct, a dictionary, a hash table, a keyed list, or an associative array. array).

2. An ordered list of values. In most languages, it is understood as an array.

These are common data structures. In fact most modern computer languages ​​support them in some form. This makes it possible for a data format to be exchanged between programming languages ​​that are also based on these structures.

JSON has the following forms:

•An object is an unordered collection of name/value pairs. An object starts with "{" (left bracket) and ends with "}" (right bracket). Each "name" is followed by a ":" (colon); "name/value" pairs are separated by a "," (comma).
•An array is an ordered collection of values. An array starts with "[" (left bracket) and ends with "]" (right bracket). Values ​​are separated by "," (comma).
•Value can be a string, number, true, false, null, object or array enclosed in double quotes. These structures can be nested.
• A string is a collection of any number of Unicode characters surrounded by double quotes and escaped with backslashes. A character is a single character string.
•Strings are very similar to C or Java strings.
•Numbers are also very similar to C or Java numbers. Remove unused octal and hexadecimal formats. Removed some encoding details.
•White space can be added between any symbols. The complete language is described below.
JSON example (using json in javascript):

Copy code The code is as follows:


Below we define the Address attribute as an array. The user has two Address:





If we want a list of users, is that possible? The answer is, no problem!





Copy code


The code is as follows:




Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template