当前位置:网站首页>What is JSON? First acquaintance with JSON
What is JSON? First acquaintance with JSON
2022-04-23 05:46:00 【DK_ ten thousand and thirty-two】
Learning goals :
Can skillfully use in development JSON Format storage data 、 How to access the JSON data
JSON The definition of :
JSON (JavaScript Object Notation) yes ⼀ A lightweight data exchange format . Easy to ⼈ Read and write . It's also easy to machine analyze and ⽣ become . It's based on JavaScript Programming Language, Standard ECMA-262 3rd Edition -December 1999 Of ⼀ individual ⼦ Set . JSON Mining ⽤ Totally alone ⽴ Yu Yu ⾔ Of ⽂ This format , But it also makes ⽤ It's similar to C language ⾔ Family habits ( Include C, C++, C#, Java, JavaScript, Perl, Python etc. ). These characteristics make JSON Become an ideal data exchange language ⾔.
In standard json In the format ,json Objects are enclosed in parentheses , The properties in the object are json Of key yes ⼀ A string , therefore ⼀ Make sure that ⽤ Double quotation marks . Each group key Between ⽤ Comma in ⾏ Separate .
Json Define format :
var Variable name = {
"key1" : value , // Number type
"key2" : "value" , // String type
"key3" : [] , // An array type
"key4" : {
}, // json object type
"key5" : [{
},{
}] // json Array
};
JSON Object access :
json object , seeing the name of a thing one thinks of its function , I know it is ⼀ Objects .⾥⾯ Of key It's the properties of the object . We are going to visit ⼀ Properties of an object ,
Just make ⽤【 Object name . Property name 】 Of ⽅ It's easy to access .
for example :
<script type="text/javascript"> // 1. Definition JSON var j1 = {
"name":" Zhang San ","age":18}; alert(j1.name+","+j1.age); // Zhang San ,18 // Array var j2 = {
"names":["aa","bb","cc"]} alert(j2.names[1]); // bb //json An array of content var j3 = {
"users":[{
"name":" Zhang San ","age":18},{
"name":" Zhang San 2","age":14},{
"name":" Zhang San 3","age":12}]}; alert(j3.users[0].name); // Zhang San </script>
The following is the page source code , Save as *.html Open the page with a browser , You can see the result directly
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JSONTest</title>
<script type="text/javascript"> // 1. Definition JSON var j1 = {
"name":" Zhang San ","age":18}; alert(j1.name+","+j1.age); // Zhang San ,18 // Array var j2 = {
"names":["aa","bb","cc"]} alert(j2.names[1]); // bb //json An array of content var j3 = {
"users":[{
"name":" Zhang San ","age":18},{
"name":" Zhang San 2","age":14},{
"name":" Zhang San 3","age":12}]}; alert(j3.users[0].name); // Zhang San </script>
</head>
<body>
<h1> JSON Study </h1>
</body>
</html>
版权声明
本文为[DK_ ten thousand and thirty-two]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220534093892.html
边栏推荐
- Range of numbers (dichotomous classic template topic)
- Mysql 查询使用\G,列转行
- ‘EddiesObservations‘ object has no attribute ‘filled‘
- AcWing 1096. Detailed notes of Dungeon Master (3D BFS) code
- Shell instruction learning 1
- shell指令学习1
- 多线程与高并发(1)——线程的基本知识(实现,常用方法,状态)
- Deep learning object detection
- Batch import of orange single micro service
- Parameter analysis of open3d material setting
猜你喜欢

OSI层常用协议

Flutter nouvelle génération de rendu graphique Impeller

Excel sets row and column colors according to cell contents

Ora: 28547 connection to server failed probable Oracle net admin error

Duplicate key update in MySQL

多线程与高并发(2)——synchronized用法详解

2-軟件設計原則

Interview Basics

转置卷积(Transposed Convolution)

Generation of straightening body in 3D slicer
随机推荐
CMake基础教程(39)pkgconfig
Formal parameters, local variables and local static variables
catkin_ What did package do
Duplicate key update in MySQL
poi生成excel,插入图片
Flutter 新一代图形渲染器 Impeller
Split and merge multiple one-dimensional arrays into two-dimensional arrays
Pytorch deep learning practice_ 11 convolutional neural network
QT displays the specified position and size of the picture
Mysql 查询使用\G,列转行
Radar equipment (greedy)
MySQL transaction
C, class library
C language - Spoof shutdown applet
Shell instruction learning 1
Qwebsocket communication
refused connection
Strategy for improving the conversion rate of independent stations | recovering abandoned users
Reading notes of modern methods of C language programming
Similarities and differences between vector and array (notes)