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

Why objects are formatted by JSON

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly explains "why the object is formatted by JSON". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn why objects are formatted by JSON.

JSON is formatted as a JavaScript object

The JSON format is syntactically the same as the code for creating JavaScript objects.

Because they are similar, JavaScript programs can easily convert JSON data into JavaScript objects.

JSON grammar rules

The data is a key / value pair.

The data is separated by commas.

Curly braces save objects

Square brackets save array

JSON data-A name corresponds to a value

JSON data is formatted as key / value pairs, just like JavaScript object properties.

The key / value pair includes the field name (in double quotes), followed by a colon, followed by the value:

"name": "Runoob"

JSON object

The JSON object is saved in curly braces.

As in JavaScript, an object can hold multiple key / value pairs:

{"name": "Runoob", "url": "www.runoob.com"}

JSON array

The JSON array is kept in square brackets.

As in JavaScript, arrays can contain objects:

"sites": [

{"name": "Runoob", "url": "www.runoob.com"}

{"name": "Google", "url": "www.google.com"}

{"name": "Taobao", "url": "www.taobao.com"}

]

In the above example, the object "sites" is an array containing three objects.

Each object is the information of the site (site name and site address).

At this point, I believe you have a deeper understanding of "why the object is formatted by JSON". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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

Development

Wechat

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

12
Report