Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What does json format mean?

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you what the json format refers to. I hope you will get something after reading this article. Let's discuss it together.

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 format for data exchange)

Using ajax for data exchange between foreground and background

Data exchange between mobile and server

Using the format and parsing of Json, you can easily represent 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, user objects are represented in json data format

{"username": "zhangsan", "age": 28, "password": "123", "addr": "Beijing"}

List is represented in json data format

[{"pid": "10", "pname": "Xiaomi 4C"}, {}, {}]

Use {enclose} as long as it is an object, and enclose as long as it is a collection.

Note: object format and array format can be nested with each other, and a property in an object can be a collection or array.

The key of json is a string, the value of json is Object

There is a username,age,password,addr,account property in this object, and the value of the account property is also an object

Give an example

After we write out the object in json format, we can get the properties of the object through the point at the object level like java. See the following example

There is a person object, and person.lastname can get the lastname value of person directly.

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

Json is an object that has a property baobao,baobao whose value is a collection, json. Baobao [1] is the first object to get the baobao value.

This json is an object, it has three properties, the first property is a simple value, the second property is an object, and the third property is a collection.

All these things are written in, so json is the native content of js, which means that js can directly extract the data in the json object. As long as the var object name = json format object, we will directly obtain the data in the object through the object format name in js without parsing

After reading this article, I believe you have a certain understanding of "what the json format means". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report