当前位置:网站首页>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
边栏推荐
- 【Visual Studio Code】vscode快捷键大全
- Longitude and latitude multipoint acquisition center point has been solved
- 15 `bs object Node name Node name String` get nested node content
- 2022资料员-通用基础(资料员)考试模拟100题及在线模拟考试
- STM32 key development foundation
- Shengxin weekly issue 34
- Making 3D romantic cool photo album [source code attached]
- Idea configuration
- 新库上线 | CnOpenData农产品批发价格数据
- Is it safe to open a fund account? Are there any risks?
猜你喜欢

Template engine - FreeMarker first experience

Essence and thoughts of 30 lectures on product thinking

halcon之区域:多种区域(Region)生成(4)

Handling of @charset UTF-8 warning problems during vite packaging and construction;

Etcd database source code analysis cluster communication initialization

idea配置

Shengxin weekly issue 33

C # operate with MySQL

返回值为Object型方法调用equals()

Design and process analysis of anti backflow circuit for MOS transistor
随机推荐
计算机网络知识总结(面试)
Web信息收集,互联网上的裸奔者
Musk vs. jobs, who is the greatest entrepreneur in the 21st century
Installation and startup of redis
集合集合!!快来复习--mysql增删改查,内、左右连接 复习笔记
Technical introduction - detailed explanation of chip manufacturing process
返回值为Object型方法调用equals()
基金开户安全吗?有没有什么风险?
JSON基本语法
信息收集的利器,Google骇客语法
MySQL例题一 综合案例(多条件组合查询)
Dgus new upgrade: fully support digital video playback function
Redis strings command
Essence and thoughts of 30 lectures on product thinking
Laravel基础课 路由和MVC——控制器
Data analysis slicer, PivotTable and PivotChart (necessary in the workplace)
15 `bs object Node name Node name String` get nested node content
Flex & bison start
黑盒测试 — 测试用例 之 判定表法看这一篇就够了
Endnote IEEE Transactions on industrial electronics/tie/tpel reference format template