Tuesday, May 22, 2018
JSON Basics
JSON Data Types
String - text enclosed in single or double quatation marks
Numbers - integer, decimal ,positive , negetive
Boolean - true or false (no quatation marks)
Null - nothing (no quatation marks)
Arrays - these are lists seperated by comma, inside square brackets ,can contain any data type
[3,4,55.4 , -8, 0, 56]
["red", "green", "blue"]
[54, "toast" , true ,null ,100]
Objects -JSON type dictionaries - means it contains as key - value pairs
dictionary enclosed by curly brackets
key and value seperated by colon
pairs seperated by comma
keys and values can be any data type
but most commonly string will be key
{"maths : "76, "science" : 80, "english" : 90}
{
"firstName" : "Indika" ,
"lastName" : "Senavirathne" ,
"age" : 35 ,
"employeed" : true
}
Nesting - Putting arrays and objects inside each other
[{
"type": "a",
"name": "Indika",
"data": [{
"name": "N1",
"ex": 3
}, {
"name": "N1",
"ex": 3
}]
}, {
"type": "a",
"name": "Indika",
"data": [{
"name": "N1",
"ex": 3
}, {
"name": "N1",
"ex": 3
}]
}, {
"type": "a",
"name": "Indika",
"data": [{
"name": "N1",
"ex": 3
}, {
"name": "N1",
"ex": 3
}]
}]
Some usefull links
https://jsonlint.com/
http://jsonviewer.stack.hu/
https://www.json-generator.com/
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment