Chapter 2
Chapter 2
Week 02:
Cloud System
• JavaScript Object Notation (JSON)
• Connecting to the Mongodb
• Mongo shell
• Javascript script
Learning Outcome
• JavaScript Object Notation (JSON)
• light-weight
• language independent
• Easy to read and write
• Text based, human readable data exchange format
{
"firstName" : "Chaitanya",
"lastName" : "Singh",
"age" : 28
}
JSON
• Standard JSON Format
{
"firstName" : "Chaitanya",
"lastName" : "Singh",
"age" : 28
JSON
• Standard JSON Format
{ key : value
"firstName" : "Chaitanya",
"lastName" : "Singh",
"age" : 28
}
JSON
• Standard JSON Format
{
"firstName" : "Chaitanya",
JSON
• Standard JSON Format
{
"firstName" : "Chaitanya",
"lastName" : "Singh",
"age" : 28,
"phone" :{
"mobile" : "0104001000", Sub-Document
"office" : "6064442022" (object list)
}
}
JSON
• Standard JSON Format
{
"firstName" : "Chaitanya",
"lastName" : "Singh",
"age" : 28,
"phone" : [
"0104001000", Array Value
"6064442022" (array list)
]
}
JSON
• Standard JSON Format
{
"firstName" : "Chaitanya",
"lastName" : "Singh",
"age" : 28,
"phone" : [
{"mobile" : "0104001000"}, Array of Key : Value
{"office" : "6064442022”}
(array of object-list)
]
}
JSON
{
"firstName" : "Chaitanya", string
"lastName" : "Singh",
"age" : 28,
"married" : false,
"phone" : null
}
JSON Validator
• https://jsonlint.com/
JSON Validator
Mongo Shell
Mongo Shell
show dbs
Mongo Shell
use <db>
Mongo Shell
show collections
Mongo Shell
db.<collection>.find({})
Mongo Shell
Nodejs
Nodejs
Nodejs
Nodejs
Homework
https://university.mongodb.com/courses/M001/about
Homework
https://ulearn-
eet.utem.edu.my/sem2202122/mod/forum/view.php?id=31366