[Study Notes] [JSON] Lightweight Data Interchange Format JSON Study Notes

Basic concepts of JSON:

JSON full name: Java Script Object Natation. That is, the object representation of JavaScript.
It has been developed into a lightweight data exchange format.

Features: Does not depend on any language, cross-platform.

The usage scenario is mainly used for data transfer between different languages

The difference between JSON and XML/Properties:
1. JSON is lightweight, while XML is heavyweight, currently XML is generally used for configuration
2. JSON is structured, and Properties are just Key/Value


JSON official website syntax:

There are mainly two formats, one is an object and the other is an array. Groups can contain objects, and objects can contain arrays.

An object
is an unordered collection of "'name/value' pairs". An object begins with "{" (left bracket) and ends with "}" (right bracket). Each 'name' is followed by a ':' (colon); 'name/value' pairs are separated by a ',' (comma).

write picture description here

example:
write picture description here

An array
is an ordered collection of values. An array starts with "[" (left bracket) and ends with "]" (right bracket). Use "," (comma) to separate the values.

write picture description here

example:
write picture description here

The value
can be a string enclosed in double quotes, a number, true, false, null, an object, or an array. These structures can be nested.
write picture description here

A string
is a collection of any number of Unicode characters enclosed in double quotes, escaped with a backslash. A character is a single character string.
JSON strings are very similar to C or Java strings.

write picture description here

The legend is actually just escaped with '\', the same as C syntax.

Numbers
are also very similar to C or Java numbers. It's just that the JSON values ​​are not in octal and hexadecimal format.
write picture description here

The diagram means that the numbers are represented like this:8.25e+7


How to handle the Static property:

In Java, static methods cannot be converted to JSON format, because static methods belong to classes, not objects.

Solution:
use map format or build Json format yourself

Example of building a Json format: In fact, it is also a Map format in the end.
JSONObject object = new JSONObject();
object.put("age", "18");


I learned the mind mapping tool before, and the content is the same as above when I use it for the first time.

write picture description here


Reference: Detailed explanation of JSON configuration on
Json official website
[fine talk about micro video]

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325987375&siteId=291194637