当前位置:网站首页>JSON basic syntax
JSON basic syntax
2022-06-26 01:27:00 【Life needs depth】
JSON Grammar is JavaScript A subset of grammar .
JSON Rule of grammar
JSON Grammar is JavaScript Object represents a subset of Syntax .
- The data is in the name / Value alignment
- Data is separated by commas
- Curly braces {} Save the object
- brackets [] Save array , An array can contain multiple objects
JSON name / It's worth it
JSON The data is written in :
key : value
name / Value pairs include field names ( In double quotes ), Write a colon at the back , Then it's worth :
"name" : " Novice tutorial "
It's easy to understand , Equivalent to this JavaScript sentence :
name = " Novice tutorial "
JSON value
JSON Values can be :
- Numbers ( Integer or floating point number )
- character string ( In double quotes )
- Boolean value (true or false)
- Array ( In brackets )
- object ( In braces )
- null
JSON Numbers
JSON Numbers can be integer or floating point :
{ "age":30 }
JSON object
JSON Objects in braces {} In the writing :
{key1 : value1, key2 : value2, ... keyN : valueN }
Object can contain multiple names / It's worth it :
{ "name":" Novice tutorial " , "url":"www.runoob.com" }
It's easy to understand , With this JavaScript Statement equivalence :
name = " Novice tutorial " url = "www.runoob.com"
JSON Array
JSON Array in brackets [] In the writing :
An array can contain multiple objects :
[ { key1 : value1-1 , key2:value1-2 }, { key1 : value2-1 , key2:value2-2 }, { key1 : value3-1 , key2:value3-2 }, ... { key1 : valueN-1 , key2:valueN-2 }, ]
{ "sites": [ { "name":" Novice tutorial " , "url":"www.runoob.com" }, { "name":"google" , "url":"www.google.com" }, { "name":" Microblogging " , "url":"www.weibo.com" } ] }
In the example above , object sites Is an array of three objects . Each object represents a website (name、url) The record of .
JSON Boolean value
JSON The Boolean value can be true perhaps false:
{ "flag":true }
JSON null
JSON You can set null value :
{ "runoob":null }
JSON Use JavaScript grammar
because JSON Use JavaScript grammar , So no additional software is needed to handle JavaScript Medium JSON.
adopt JavaScript, You can create an array of objects , And assign values like this :
example
var sites = [ { "name":"runoob" , "url":"www.runoob.com" }, { "name":"google" , "url":"www.google.com" }, { "name":" Microblogging " , "url":"www.weibo.com" } ];
You can visit... Like this JavaScript The first item in an array of objects ( Index from 0 Start ):
sites[0].name;
The content returned is :
runoob
You can modify the data like this :
sites[0].name=" Novice tutorial ";
In the next chapter , You will learn how to put JSON The text is converted to JavaScript object .
JSON file
- JSON The file type of the file is .json
- JSON Textual MIME The type is application/json
边栏推荐
- Flex & Bison 开始
- Template engine - FreeMarker first experience
- Xinku online | cnopendata text data of IPO declaration and issuance of A-share listed companies
- 剑指 Offer II 096. 字符串交织
- About EF page turning query database
- C thread pool control semaphore
- 毕业季你考虑好去留了吗
- Reading notes on how to connect the network - hubs, routers and routers (III)
- JSON实例(一)
- 模板引擎——FreeMarker初体验
猜你喜欢
Remote incremental synchronization artifact Rsync
From query database performance optimization to redis cache - talk about cache penetration, avalanche and breakdown
I2C protocol
Region of Halcon: generation of multiple regions (4)
Zhihuijia - full furniture function
物联网?快来看 Arduino 上云啦
Template engine - FreeMarker first experience
Handling of @charset UTF-8 warning problems during vite packaging and construction;
Essence and thoughts of 30 lectures on product thinking
When you run the demo using the gin framework, there is an error "listen TCP: 8080: bind: an attempt was made to access a socket in a way forbidden"
随机推荐
New library launched | cnopendata wholesale price data of agricultural products
黑盒测试 — 测试用例 之 判定表法看这一篇就够了
C thread pool control semaphore
Shengxin weekly issue 34
Simple deepclone
**MySQL例题一(根据不同问题,多条件查询)**
ASP. Net cache cache usage
完整复习(包含语法)--MYSQL正则表达式
Using redis database as cache in Django
Inheritance -- holy grail mode
Oracle数据库开启备份准备工作
Region of Halcon: generation of multiple regions (4)
Installation and startup of redis
MOS管防倒灌电路设计及其过程分析
快速生成1~20自然数,并轻松复制
. Net using access 2010 database
JSON基本语法
走 迷 宫
Tools - API document generation tool
信息收集的利器,Google骇客语法