SlideShare une entreprise Scribd logo
1  sur  10
Télécharger pour lire hors ligne
Introduction to JSON
JavaScript Object Notation
1. JavaScript Object Notation (JSON) is a text format for the
serialization of structured data. It comes from object literals in
JavaScript.
2. JSON can represent four primitive types (strings, numbers,
booleans, and null) and two structured types (objects and arrays).
3. A string is a sequence of zero or more Unicode characters.
4. An object is an unordered collection of zero or more name/value
pairs, where a name is a string and a value is a string, number,
boolean, null, object, or array. An array is an ordered sequence of
zero or more values.
5. JSON's design goals were for it to be minimal, portable, textual,
and a subset of JavaScript.
2
About JSON
● Data-centric
● Requires name:value pairs
● Serializes data
● Smaller file size, fast
● Made of Arrays and Objects
● Subset of JavaScript
● Plays well with jQuery
3
Working with JSON
Like XML, JSON can be a text file as in
staticdata.json
JSON usually comes from a server such as
http://api.openweathermap.org/data/2.
5/weather?q=tustin,%20ca
4
[
{
"displayname": "Bruce Lee",
"email": "Bruce.lee@karate.com",
"department": "stockroom"
},
{
"displayname": "mike",
"email": "mike@Cathy.com ",
"department": "kitchen"
},
{
"displayname": "scott",
"email": "scott@Cathy.com ",
"department": "Office"
}
]
static.json Example
5
Creating JSON
1. Create a file and call it contacts.json
2. Type Name="Your Name Here"
3. Replace this with an array Contacts=["your name","
friend1","friend2"]
4. Turn the Array into an Object by replacing the [ ] with { }
and adding name:value pairs Contacts = {"Name": "your
name","Address": "123 Main Street","Phone Numbers":
["714-432-1234","714-8310-9754","714-765-4534"]}
6
Creating JSON (p2)
1. Contacts can now be used. Copy the code between the {
} and paste it into http://jsonlint.com and click validate
2. If it is correct then it will say Valid JSON Modify the JSON until it
does.
3. Add 2 more people to the Contacts JSON file and
validate it.
7
Creating JSON (p3)
1. contacts.json can now be used in a web application as it is.
2. You can also declare a JavaScript variable with it like this:
var Contacts = {"Name": "your name","Address": "123 Main Street","Phone
Numbers": ["714-432-1234", "714-8310-9754", "714-765-4534"]};
3. Copy the above variable, and open the Chrome web browser
4. Right-click on the page and select Inspect Element, then click the Console
tab
5. Paste the JavaScript variable into the console and press enter. Then type
console.log(Contacts);
6. Notice the Object {Name: "your name", Address: "123 Main Street", Phone Numbers: Array[3]}
7. Open the Object and find the phone numbers inside it
8
Review
● JSON is widely used
● The syntax is simple and easily readable
● It is light-weight and great for using in AJAX-
driven User Interfaces such as those created
with jQuery UI
9
JSON Resources
http://jsonformatter.curiousconcept.com
http://jsonlint.com
JSON View Chrome Browser Extension
https://chrome.google.
com/webstore/detail/jsonview/chklaanhfefbnpoi 10

Contenu connexe

Tendances (20)

JSON
JSONJSON
JSON
 
Java Script Object Notation (JSON)
Java Script Object Notation (JSON)Java Script Object Notation (JSON)
Java Script Object Notation (JSON)
 
java script json
java script jsonjava script json
java script json
 
Introduction to JSON
Introduction to JSONIntroduction to JSON
Introduction to JSON
 
JSON - Quick Overview
JSON - Quick OverviewJSON - Quick Overview
JSON - Quick Overview
 
Json
JsonJson
Json
 
JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)
 
Json
JsonJson
Json
 
Json
JsonJson
Json
 
Json
JsonJson
Json
 
Json
JsonJson
Json
 
MongoMapper lightning talk
MongoMapper lightning talkMongoMapper lightning talk
MongoMapper lightning talk
 
Mongo DB
Mongo DBMongo DB
Mongo DB
 
Brief Introduction to REST
Brief Introduction to RESTBrief Introduction to REST
Brief Introduction to REST
 
RESTful JSON web databases
RESTful JSON web databasesRESTful JSON web databases
RESTful JSON web databases
 
JSON and MongoDB in R
JSON and MongoDB in RJSON and MongoDB in R
JSON and MongoDB in R
 
Mongo learning series
Mongo learning series Mongo learning series
Mongo learning series
 
An Introduction to JSON JavaScript Object Notation
An Introduction to JSON JavaScript Object NotationAn Introduction to JSON JavaScript Object Notation
An Introduction to JSON JavaScript Object Notation
 
Mongo DB schema design patterns
Mongo DB schema design patternsMongo DB schema design patterns
Mongo DB schema design patterns
 
Mongo db Quick Guide
Mongo db Quick GuideMongo db Quick Guide
Mongo db Quick Guide
 

Similaire à Intro to JSON (20)

All about XML, JSON and related topics..
All about XML, JSON and related topics..All about XML, JSON and related topics..
All about XML, JSON and related topics..
 
Json
JsonJson
Json
 
Working with JSON
Working with JSONWorking with JSON
Working with JSON
 
An introduction to json
An introduction to jsonAn introduction to json
An introduction to json
 
Working with JSON.pptx
Working with JSON.pptxWorking with JSON.pptx
Working with JSON.pptx
 
Basics of JSON (JavaScript Object Notation) with examples
Basics of JSON (JavaScript Object Notation) with examplesBasics of JSON (JavaScript Object Notation) with examples
Basics of JSON (JavaScript Object Notation) with examples
 
Hands on JSON
Hands on JSONHands on JSON
Hands on JSON
 
JSON & AJAX.pptx
JSON & AJAX.pptxJSON & AJAX.pptx
JSON & AJAX.pptx
 
Advanced Json
Advanced JsonAdvanced Json
Advanced Json
 
Json tutorial, a beguiner guide
Json tutorial, a beguiner guideJson tutorial, a beguiner guide
Json tutorial, a beguiner guide
 
Intro to JSON
Intro to JSONIntro to JSON
Intro to JSON
 
JSON Injection
JSON InjectionJSON Injection
JSON Injection
 
Json
Json Json
Json
 
JSON-(JavaScript Object Notation)
JSON-(JavaScript Object Notation)JSON-(JavaScript Object Notation)
JSON-(JavaScript Object Notation)
 
Json – java script object notation
Json – java script object notationJson – java script object notation
Json – java script object notation
 
JSON - JavaScript Object Notation
JSON - JavaScript Object NotationJSON - JavaScript Object Notation
JSON - JavaScript Object Notation
 
Json – java script object notation
Json – java script object notationJson – java script object notation
Json – java script object notation
 
JSON Data Parsing in Snowflake (By Faysal Shaarani)
JSON Data Parsing in Snowflake (By Faysal Shaarani)JSON Data Parsing in Snowflake (By Faysal Shaarani)
JSON Data Parsing in Snowflake (By Faysal Shaarani)
 
Pythonlearn-13-WebServices.pptx
Pythonlearn-13-WebServices.pptxPythonlearn-13-WebServices.pptx
Pythonlearn-13-WebServices.pptx
 
Json at work overview and ecosystem-v2.0
Json at work   overview and ecosystem-v2.0Json at work   overview and ecosystem-v2.0
Json at work overview and ecosystem-v2.0
 

Dernier

Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdfSuman Jyoti
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...tanu pandey
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptMsecMca
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 

Dernier (20)

Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 

Intro to JSON

  • 2. JavaScript Object Notation 1. JavaScript Object Notation (JSON) is a text format for the serialization of structured data. It comes from object literals in JavaScript. 2. JSON can represent four primitive types (strings, numbers, booleans, and null) and two structured types (objects and arrays). 3. A string is a sequence of zero or more Unicode characters. 4. An object is an unordered collection of zero or more name/value pairs, where a name is a string and a value is a string, number, boolean, null, object, or array. An array is an ordered sequence of zero or more values. 5. JSON's design goals were for it to be minimal, portable, textual, and a subset of JavaScript. 2
  • 3. About JSON ● Data-centric ● Requires name:value pairs ● Serializes data ● Smaller file size, fast ● Made of Arrays and Objects ● Subset of JavaScript ● Plays well with jQuery 3
  • 4. Working with JSON Like XML, JSON can be a text file as in staticdata.json JSON usually comes from a server such as http://api.openweathermap.org/data/2. 5/weather?q=tustin,%20ca 4
  • 5. [ { "displayname": "Bruce Lee", "email": "Bruce.lee@karate.com", "department": "stockroom" }, { "displayname": "mike", "email": "mike@Cathy.com ", "department": "kitchen" }, { "displayname": "scott", "email": "scott@Cathy.com ", "department": "Office" } ] static.json Example 5
  • 6. Creating JSON 1. Create a file and call it contacts.json 2. Type Name="Your Name Here" 3. Replace this with an array Contacts=["your name"," friend1","friend2"] 4. Turn the Array into an Object by replacing the [ ] with { } and adding name:value pairs Contacts = {"Name": "your name","Address": "123 Main Street","Phone Numbers": ["714-432-1234","714-8310-9754","714-765-4534"]} 6
  • 7. Creating JSON (p2) 1. Contacts can now be used. Copy the code between the { } and paste it into http://jsonlint.com and click validate 2. If it is correct then it will say Valid JSON Modify the JSON until it does. 3. Add 2 more people to the Contacts JSON file and validate it. 7
  • 8. Creating JSON (p3) 1. contacts.json can now be used in a web application as it is. 2. You can also declare a JavaScript variable with it like this: var Contacts = {"Name": "your name","Address": "123 Main Street","Phone Numbers": ["714-432-1234", "714-8310-9754", "714-765-4534"]}; 3. Copy the above variable, and open the Chrome web browser 4. Right-click on the page and select Inspect Element, then click the Console tab 5. Paste the JavaScript variable into the console and press enter. Then type console.log(Contacts); 6. Notice the Object {Name: "your name", Address: "123 Main Street", Phone Numbers: Array[3]} 7. Open the Object and find the phone numbers inside it 8
  • 9. Review ● JSON is widely used ● The syntax is simple and easily readable ● It is light-weight and great for using in AJAX- driven User Interfaces such as those created with jQuery UI 9
  • 10. JSON Resources http://jsonformatter.curiousconcept.com http://jsonlint.com JSON View Chrome Browser Extension https://chrome.google. com/webstore/detail/jsonview/chklaanhfefbnpoi 10