About JSON Json schema prelude


1. What is JSON

JSON (JavaScript Object Notation), i.e., JavaScript Object Notation. JSON is mainly used to store and exchange text messages, similar to XML. But compared and XML, JSON is more lightweight data interchange format text, with a smaller, faster, easier to resolve features. JSON self descriptive, easier to understand. Although JSON using JavaScript syntax to describe data objects, however, JSON is independent of language and platform. JSON parser and JSON library supports many different programming languages.

2. JSON basic grammar

JavaScript Object Notation JSON syntax is a subset of the syntax of law. Details are as follows:

  • Data stored in key / value
  • Data separated by commas
  • Save Object braces
  • Save the data in square brackets

Type 3. JSON value

JSON data are key / value pairs are stored, wherein this value, optional type as follows:

  • Number (integer or floating point), for example: { "number": 12.34}

  • String (in double quotes), for example: { "name": "qiumengchen"}

  • A logical value (true or false), for example: { "isOpen": true}

  • An array (in parentheses), for example: { "array": [1.2, "3", true, [4,5], { "test": "ok"}, null]}

  • Object (braces), for example: { "person": { "name": "qiumengchen", "isHandsome": true}}

  • null, for example: { "blog": null}

Overall, the full form of JSON in two ways:

  • JSON object: braces ({}) as a symbol, an object may comprise a plurality of key / value pairs, note: each object must be of key / value pairs, not other forms. However, where the key must be a string, where the value may be valid JSON data types: numeric, string, logical values, arrays, objects, and the like null. E.g:
{
    "name": "qiumengchen",
    "isHandsome": true,
    "blog": {
        "url": "qiumengchen.top",
        "name": "myBlog"
    }
}
  • JSON array: in brackets ([]) for the flag, an array may comprise a plurality of value, value may be valid JSON data types: numeric, string, logical values, arrays, objects, and the like null. However, in general, we will maintain the consistency of form and meaning of each item of data, easy to understand and use. E.g:
[ 99 , "qiumengchen" , true , [1,2,3] , {"name":"qiumengchen"} , null ]

4. Compared with XML

In common with XML

  • JSON is a text
  • JSON has "self-descriptive" (human readable)
  • JSON has a hierarchical structure (in the presence of values)
  • JSON can be parsed by JavaScript
  • JSON data may be transmitted using AJAX

The difference with XML

  • No end tag
  • Shorter
  • Faster read and write
  • It can be built using JavaScript eval () methods to parse
  • Using arrays
  • Do not use a reserved word

5. aid

JSON online analysis tool (features include: JSON format, compression, verification format, JSON turn XML, CSV, YAML), at the following address: https://c.runoob.com/front-end/53
Chrome browser plug-ins: JSON -handle

Original: https://blog.csdn.net/qiumengchen12/article/details/72283079

Guess you like

Origin www.cnblogs.com/ChangAn223/p/11234326.html