There are two json formats, namely: 1. Object format [{"key1":obj, "key2":obj, "key3":obj...}]; 2. Array or collection format , [[obj,obj,obj...]].
The role of json (json is a language-independent data exchange format)
-
Use ajax for front-end and back-end data exchange
Data exchange between mobile terminal and server
It is convenient to use Json format and parsing Represents an object information, json has two formats:
1) Object format: {"key1":obj,"key2":obj,"key3":obj...}
2) Array/collection format: [obj, obj, obj...]
For example: the user object is represented in json data format
{"username":"zhangsan","age":28,"password":"123","addr":"北京"}
List
[{"pid":"10","pname":"小米4C"},{},{}]
As long as it is an object, use {enclosed}, as long as it is a collection, use []enclosed
Note: Object format and array format can be nested in each other, an object An attribute in can be a collection or array
The key of json is a string and the value of json is Object
This object contains username, age , password, addr, account attributes, where the value of the account attribute is also an object
Example
After we write the object in json format, we want to get this The attributes of the object can be obtained by just clicking on the object level one level like Java. See the following example
This one has a person object, person.lastname You can directly get the value of person's lastname
This person is a collection, there are two objects in the collection, person[1] is the first object in the collection
json is an object. This object has an attribute baobao. The value of baobao is a collection, json. baobao[1] is the first object to obtain the baobao value
This json is an object with three attributes. The first attribute is a simple value. The second attribute is an object, and the third attribute is a collection.
The above things are all written in <script>, so json is the native content of js, which means that js can directly To take out the data in the json object, as long as the var object name = json format object, we can directly obtain the data in the object through the name of the object format in js without parsing </script>
Related free recommendations: Programming Video Course
The above is the detailed content of What is json format. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Linux new version
SublimeText3 Linux latest version
