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

How to use json in JavaScript

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly explains "how to use json in JavaScript". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use json in JavaScript.

What is JSON?

"JSON" means JavaScript Object Notation.

JSON is a lightweight data exchange format

JSON is language independent *

JSON is "self-describing" and easy to understand

* the syntax of JSON is from the syntax of JavaScript object symbols, but the JSON format is plain text. The code that reads and generates JSON data can be written in any programming language.

JSON instance

The JSON syntax defines an employee object: an array (object) containing three employee records:

JSON instance

{

"employees": [

{"firstName": "Bill", "lastName": "Gates"}

{"firstName": "Steve", "lastName": "Jobs"}

{"firstName": "Alan", "lastName": "Turing"}

]

}

JSON format is evaluated as a JavaScript object

The JSON format is syntactically the same as the code that creates the JavaScript object.

Because of this similarity, JavaScript programs can easily convert JSON data into native JavaScript objects.

JSON grammar rules

The data is a name / value pair

Data is separated by commas

Curly braces save objects

Square brackets save array

JSON data-name and value

JSON data is written as name / value pairs, similar to JavaScript object properties.

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

"firstName": "Bill"

The JSON name requires double quotation marks. The JavaScript name is not required.

At this point, I believe you have a deeper understanding of "how to use json in JavaScript". 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