JSON Syntax
Next ❯Ways to Add
- JSON syntax is derived from JavaScript object notation syntax
- JSON is just a string in object notation syntax format
- turned_in_notSyntax
/* Syntax-In JSON */
{ "key":value }
/* Syntax-In javaScript */
{ key:value }
- Remember!
- Name of the key is case-sensitive
Name of the key is always started with an alphabet and can only carry alphabets & numbers
In JSON key must be declared inside double quotes (" ") but in javaScript choice is yours
Example:
- turned_in_notSyntax Sample
{ "name":"Riya", "age":23 }
- turned_in_notSyntax Description
- Key must be declared inside double quotes (" ")
- Key & value are separated by colon (:)
- All Key & value are declared inside curly brackets
- Multiple Key & value are separated by comma (,)
JSON Values
Json values can be only one of the following data types
- turned_in_notData Types
- String
- Number
- Array
- Object
- Boolean
- Null
Example:
- label_outlineString Type
{ "name":"Riya" }
- Note! String value must be written inside double quotes (" ")
- label_outlineNumber Type
{ "age":23 }
- Note! Number values can be only integer/float
- label_outlineArray Type
{ "courses":["html","css","css3"] }
- Note! Array value must be written inside square brackets
[ ]
- Note! Array value must be written inside square brackets
- label_outlineObject Type
{ "phone":{ "modal":"iphone X", "color":"black", "price":"$999" } }
- Note! Object value must be written inside curly brackets
- Note! Object value must be written inside curly brackets
- label_outlineBoolean Type
{ "pass":true }
- Note! Boolean values can be only true/false
- label_outlineNull Type
{ "quantity":null }
- Note! Null values can be only
null
- null means empty
- Note! Null values can be only
❮ Prev Getting Started
Next ❯Ways to Add