Home > Article > Web Front-end > JSON must be known and understood Postscript
Term
Portability
Compatibility of transferring information between platforms and systems.
JSON
JavaScriptObjectNotation object notation.
Data Interchange Format
Text used for exchanging data between different platforms or systems.
Literal
The literal meaning is exactly the same as the value it wants to express.
Variable
is represented by an identifier in the form of X and is a type of value that can be modified.
Maximum portability
Provides portability beyond the data format itself by ensuring the compatibility of the data itself with platforms and systems.
Name-value pairs
refer to attributes and characteristics that have names and corresponding values (also called key-value pairs).
Syntax verification
json format verification.
Consistency Verification
Focus on unique data structure verification.
String type in JSON
A string value, such as "You are a good person", is wrapped in double quotes.
Concept
JSON is a data exchange format.
JSON is programming language independent.
JSON is based on the literal representation of JavaScript objects (the emphasis is on the representation).
The way JSON expresses data is friendly to common programming concepts.
JSON is based on the syntax of JavaScript object literals to represent properties, but does not include the function-related parts of JavaScript object literals.
In JSON name-value pairs, the name is always wrapped in double quotes.
JSON name-value pair, the value can be a string, number, Boolean value, null, object array.
Lists of name-value pairs in JSON are always wrapped in curly braces.
Multiple name value pairs in JSON are separated by commas.
JSON files use the .json extension.
The media type of JSON is application/json.
The Boolean values in JSON are only true and false, and all letters must be lowercase.
All letters of the null value in JSON must be lowercase to indicate a null value.
Number type in JSON, a numeric value, such as 66, can be a positive integer, a negative integer, a decimal, or an exponent.
The key difference between objects and arrays is that objects are lists or collections of name-value pairs, and arrays are lists and collections of values.
Another key difference between objects and arrays is that all values in an array should have the same data type.
Terminology
Array in JSON
An array is a collection or list of values, each value can be any of string, number, boolean, object or array. Arrays must be wrapped in [] and separated by commas.
Object types in JSON
An object type is a collection of name-value pairs separated by commas and wrapped with {}.
JSON Schema
A virtual contract in data exchange.
Server (in web development)
A series of operations performed on the server when web resources are requested. The server provides the Internet browser with responses that it processes and loads.
Client (in web development)
A series of operations performed when the interface requested by the browser is loaded, usually referring to HTML, CSS and JavaScript.
Concept
JSON validator is responsible for verifying syntax errors, and JSON Schema is responsible for providing consistency verification.
JSONSchema is the first line of defense responsible for data reception. It is also a good tool for the data sender to save time and ensure that the data is correct.
JSONSchema can solve the following consistency verification problems
1. Is the data type of the value correct? You can specify that a value is a number, string, etc. type.
2. Does it contain the required data? You can specify which data is required and which is not.
3. Is the value in the form I need? You can specify a range, minimum value and maximum value.
JSON itself poses no threat, it’s just text.
When locating JSON security issues, you should remember the following 3 things.
1. Do not use top-level arrays. Top-level arrays are legal JavaScript scripts. They can be linked and used with the