Get the App
SLTechnology News&Howtos  ›  Development  › 

Why objects are formatted by JSON

Shulou Source: shulou.com Published: 2022-06-01 12:48:08 09月30日 Update

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!

Tags: Object format data array website content name parenthesis syntax learning practical deeper similar same three code information interest colon address Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Huawei Shulou Information MariaDB Xiaomi