This article mainly shares with you what json is, so that you can fully master json, and I hope it can help you.
1.What isjson
The full English name of json is JavaScript Object Notation (it is an independent language and does not belong to JavaScript!!!)
json is a lightweight data exchange format that is easy to understand.
2.json syntax rules
Data is key/value pairs.
Data is separated by commas
Curly brackets save the object
Square brackets save the array
Key-value pair:
The key and value are both in double quotes, with a colon in the middle (equivalent to the equal sign), indicating a set of data
"name":"json"
Object:
{"name":"json","sex":"boy"}
Array:
"res":[ {"firstName":"Tom","where":"A"}, {"firstName":"John","where":"B"}, {"firstName":"Sam","where":"C"} ]
Format explanation
1. An object can have multiple attributes, one attribute corresponds to one value, the object is used { } , the attributes and values must be wrapped with "", the attributes and values are separated by fire, and the attributes are separated by fire. Separate with commas,
For example: {fiestName” : “Tom”, “where” : “A” }
2.Use commas between multiple objects Separate;
3.The value can be an array, and the array contains many objects
4.jsonThe outermost layer needs to be { }Package
Related recommendations:
Detailed explanation of json_encode() and json_decode() functions in php
How to output json object in php
How to read local json file in php
The above is the detailed content of Completely master json. For more information, please follow other related articles on the PHP Chinese website!