当前位置:网站首页>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
边栏推荐
- Flutter 新一代圖形渲染器 Impeller
- io. lettuce. core. RedisCommandExecutionException: ERR wrong number of arguments for ‘auth‘ command
- Cmake basic tutorial (39) pkgconfig
- Introduction to qqueue
- MySQL triggers, stored procedures, stored functions
- 尚硅谷 p290 多态性练习
- POI generates excel and inserts pictures
- 第36期《AtCoder Beginner Contest 248 打比赛总结》
- catkin_package到底干了什么
- Jiugong magic square - the 8th Lanqiao provincial competition - group C (DFS and comparison of all magic square types)
猜你喜欢

Establish excel bookkeeping book through setting context menu

橙单微服务之批量导入

Data mining -- understanding data

Hongji micro classroom | cyclone RPA's "flexible digital employee" actuator

deep learning object detection

Hongji cyclone RPA provides technical support for Guojin securities and realizes process automation in more than 200 business scenarios

Isosceles triangle - the 9th Lanqiao provincial competition - group C

open3d材质设置参数分析

2 - principes de conception de logiciels

Ora: 28547 connection to server failed probable Oracle net admin error
随机推荐
catkin_ What did package do
Introduction to data security -- detailed explanation of database audit system
mysql-触发器、存储过程、存储函数
Excel sets row and column colors according to cell contents
OSI层常用协议
io.lettuce.core.RedisCommandExecutionException: ERR wrong number of arguments for ‘auth‘ command
POI exports to excel, and the same row of data is automatically merged into cells
C, class library
Idea plug-in --- playing songs in the background
Flutter 新一代图形渲染器 Impeller
Introduction to qqueue
Golang implements Ping connectivity detection case through exec module
MySQL triggers, stored procedures, stored functions
Parameter analysis of open3d material setting
QT displays the specified position and size of the picture
Linear sieve method (prime sieve)
Insert picture in freemark
refused connection
refused connection
Add days to date