当前位置:网站首页>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
边栏推荐
- Pol / select / EPO
- 转置卷积(Transposed Convolution)
- [machine learning] scikit learn introduction
- Pilotage growth · ingenuity empowerment -- yonmaster developer training and pilotage plan is fully launched
- Issue 36 summary of atcoder beginer contest 248
- Range of numbers (dichotomous classic template topic)
- XXL job pit guide XXL RPC remoting error (connect timed out)
- mysql中duplicate key update
- 手动删除eureka上已经注册的服务
- Split and merge multiple one-dimensional arrays into two-dimensional arrays
猜你喜欢
deep learning object detection
Use of qwbengneview and qwebchannel.
Common protocols of OSI layer
Batch import of orange single micro service
MySQL lock mechanism
Duplicate key update in MySQL
Flutter 新一代圖形渲染器 Impeller
Pilotage growth · ingenuity empowerment -- yonmaster developer training and pilotage plan is fully launched
多线程与高并发(1)——线程的基本知识(实现,常用方法,状态)
mysql实现主从复制/主从同步
随机推荐
Golang implements Ping connectivity detection case through exec module
C语言——恶搞关机小程序
Common interview questions - 4 (MySQL)
Excel sets row and column colors according to cell contents
Object to map
excel获取两列数据的差异数据
QSslSocket::connectToHostEncrypted: TLS initialization failed
Usage and difference of shellexecute, shellexecuteex and winexec in QT
转置卷积(Transposed Convolution)
Sea Level Anomaly 和 Sea Surface Height Anomaly 的区别
MySQL创建oracle练习表
Frequently asked interview questions - 3 (operating system)
[machine learning] scikit learn introduction
多线程与高并发(3)——synchronized原理
Pavlov and hobbies
ES6之解构函数
Split and merge multiple one-dimensional arrays into two-dimensional arrays
io. lettuce. core. RedisCommandExecutionException: ERR wrong number of arguments for ‘auth‘ command
Common protocols of OSI layer
热键,界面可视化配置(界面交互)