What is JSON ?
- JavaScript Object Notation.
- Lightweight data-interchange format.
- Based on a subset of JavaScript.
- Easy to read and write.
- Often used with AJAX(Asynchronous JavaScript XML).
- Can be used with most modern languages.
Data Types
Number : No difference between integer and floats.
String : string of Unicode characters. Use double quotes.
Boolean : True or False.
Array : Ordered list of 0 or more values.
Object : Unordered collection of key/value pairs.
Null : Empty values.
💡 Tip One way to remember JSON-valid data types: BASONN:
- Booleans
- Arrays
- Strings
- Objects
- Numbers
- Null
JSON Syntax Rules
- Use key/value pairs - {"name":"John"}
- Uses double quotes around KEY and VALUES.
- Must use the specific data types.
- File type is ".json".
- MIME type is "Application/json".
JSON Example
{
"name": "John",
"age": 35,
"address":{
"street":"5 main street",
"city": "Boston"
},
"children": ["Michel","Nick"]
}
Top comments (0)