search
HomeCommon ProblemWhat is json format

What is json format

Oct 30, 2020 am 11:28 AM
json format

There are two json formats, namely: 1. Object format [{"key1":obj, "key2":obj, "key3":obj...}]; 2. Array or collection format , [[obj,obj,obj...]].

What is json format

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 json data format representation

[{"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

What is json format

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

What is json format

This one has a person object, person.lastname You can directly get the value of person's lastname

What is json format

This person is a collection, there are two objects in the collection, person[1] is the first object in the collection

What is json format

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

What is json format

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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment