SlideShare a Scribd company logo
1 of 28
JSON: The Basics
Overview
 What is JSON?
 Comparisons with XML
 Syntax
 Data Types
 Usage
 Live Examples
What is JSON?
JSON is…
 A lightweight text based data-interchange format
 Completely language independent
 Based on a subset of the JavaScript Programming
Language
 Easy to understand, manipulate and generate
JSON is NOT…
 Overly Complex
 A “document” format
 A markup language
 A programming language
Why use JSON?
 Straightforward syntax
 Easy to create and manipulate
 Can be natively parsed in JavaScript using eval()
 Supported by all major JavaScript frameworks
 Supported by most backend technologies
JSON vs. XML
Much Like XML
 Plain text formats
 “Self-describing“ (human readable)
 Hierarchical (Values can contain lists of objects or
values)
Not Like XML
 Lighter and faster than XML
 JSON uses typed objects. All XML values are type-
less strings and must be parsed at runtime.
 Less syntax, no semantics
 Properties are immediately accessible to JavaScript
code
Knocks against JSON
 Lack of namespaces
 No inherit validation (XML has DTD and
templates, but there is JSONlint)
 Not extensible
 It’s basically just not XML
Syntax
JSON Object Syntax
 Unordered sets of name/value pairs
 Begins with { (left brace)
 Ends with } (right brace)
 Each name is followed by : (colon)
 Name/value pairs are separated by , (comma)
JSON Example
var employeeData = {
"employee_id": 1234567,
"name": "Jeff Fox",
"hire_date": "1/1/2013",
"location": "Norwalk, CT",
"consultant": false
};
Arrays in JSON
 An ordered collection of values
 Begins with [ (left bracket)
 Ends with ] (right bracket)
 Name/value pairs are separated by , (comma)
JSON Array Example
var employeeData = {
"employee_id": 1236937,
"name": "Jeff Fox",
"hire_date": "1/1/2013",
"location": "Norwalk, CT",
"consultant": false,
"random_nums": [ 24,65,12,94 ]
};
Data Types
Data Types: Strings
 Sequence of 0 or more Unicode characters
 Wrapped in "double quotes“
 Backslash escapement
Data Types: Numbers
 Integer
 Real
 Scientific
 No octal or hex
 No NaN or Infinity – Use null instead.
Data Types: Booleans & Null
 Booleans: true or false
 Null: A value that specifies nothing or no value.
Data Types: Objects & Arrays
 Objects: Unordered key/value pairs wrapped in { }
 Arrays: Ordered key/value pairs wrapped in [ ]
JSON Usage
How & When to use JSON
 Transfer data to and from a server
 Perform asynchronous data calls without requiring
a page refresh
 Working with data stores
 Compile and save form or user data for local
storage
Where is JSON used today?
 Anywhere and everywhere!
And many,
many more!
Simple Example
Simple Demo
 Build a JSON data object in code
 Display raw output
 Display formatted output
 Manipulate via form input
encode Encodes the
Python object
into a JSON
string
representation.
decode Decodes a
JSON-encoded
string into a
Python object.
Python JSON
dict object
list, tuple array
str string
int, long, float number
True true
False false
None null
Questions?

More Related Content

Similar to JSON Basics: Lightweight Data Format

Similar to JSON Basics: Lightweight Data Format (20)

Java script object notation(json)
Java script object notation(json)Java script object notation(json)
Java script object notation(json)
 
Java Script Object Notation (JSON)
Java Script Object Notation (JSON)Java Script Object Notation (JSON)
Java Script Object Notation (JSON)
 
Json
JsonJson
Json
 
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
 
json.ppt download for free for college project
json.ppt download for free for college projectjson.ppt download for free for college project
json.ppt download for free for college project
 
JSON - (English)
JSON - (English)JSON - (English)
JSON - (English)
 
Json demo
Json demoJson demo
Json demo
 
JSON.pptx
JSON.pptxJSON.pptx
JSON.pptx
 
Json
JsonJson
Json
 
json
jsonjson
json
 
JSON.pptx
JSON.pptxJSON.pptx
JSON.pptx
 
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 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)
 
Json
JsonJson
Json
 
Json - ideal for data interchange
Json - ideal for data interchangeJson - ideal for data interchange
Json - ideal for data interchange
 
Json
JsonJson
Json
 
Json
JsonJson
Json
 
Json the-x-in-ajax1588
Json the-x-in-ajax1588Json the-x-in-ajax1588
Json the-x-in-ajax1588
 
Javascript2839
Javascript2839Javascript2839
Javascript2839
 
Json
JsonJson
Json
 

Recently uploaded

Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsAndrey Dotsenko
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 

Recently uploaded (20)

Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 

JSON Basics: Lightweight Data Format

  • 2. Overview  What is JSON?  Comparisons with XML  Syntax  Data Types  Usage  Live Examples
  • 4. JSON is…  A lightweight text based data-interchange format  Completely language independent  Based on a subset of the JavaScript Programming Language  Easy to understand, manipulate and generate
  • 5. JSON is NOT…  Overly Complex  A “document” format  A markup language  A programming language
  • 6. Why use JSON?  Straightforward syntax  Easy to create and manipulate  Can be natively parsed in JavaScript using eval()  Supported by all major JavaScript frameworks  Supported by most backend technologies
  • 8. Much Like XML  Plain text formats  “Self-describing“ (human readable)  Hierarchical (Values can contain lists of objects or values)
  • 9. Not Like XML  Lighter and faster than XML  JSON uses typed objects. All XML values are type- less strings and must be parsed at runtime.  Less syntax, no semantics  Properties are immediately accessible to JavaScript code
  • 10. Knocks against JSON  Lack of namespaces  No inherit validation (XML has DTD and templates, but there is JSONlint)  Not extensible  It’s basically just not XML
  • 12. JSON Object Syntax  Unordered sets of name/value pairs  Begins with { (left brace)  Ends with } (right brace)  Each name is followed by : (colon)  Name/value pairs are separated by , (comma)
  • 13. JSON Example var employeeData = { "employee_id": 1234567, "name": "Jeff Fox", "hire_date": "1/1/2013", "location": "Norwalk, CT", "consultant": false };
  • 14. Arrays in JSON  An ordered collection of values  Begins with [ (left bracket)  Ends with ] (right bracket)  Name/value pairs are separated by , (comma)
  • 15. JSON Array Example var employeeData = { "employee_id": 1236937, "name": "Jeff Fox", "hire_date": "1/1/2013", "location": "Norwalk, CT", "consultant": false, "random_nums": [ 24,65,12,94 ] };
  • 17. Data Types: Strings  Sequence of 0 or more Unicode characters  Wrapped in "double quotes“  Backslash escapement
  • 18. Data Types: Numbers  Integer  Real  Scientific  No octal or hex  No NaN or Infinity – Use null instead.
  • 19. Data Types: Booleans & Null  Booleans: true or false  Null: A value that specifies nothing or no value.
  • 20. Data Types: Objects & Arrays  Objects: Unordered key/value pairs wrapped in { }  Arrays: Ordered key/value pairs wrapped in [ ]
  • 22. How & When to use JSON  Transfer data to and from a server  Perform asynchronous data calls without requiring a page refresh  Working with data stores  Compile and save form or user data for local storage
  • 23. Where is JSON used today?  Anywhere and everywhere! And many, many more!
  • 25. Simple Demo  Build a JSON data object in code  Display raw output  Display formatted output  Manipulate via form input
  • 26. encode Encodes the Python object into a JSON string representation. decode Decodes a JSON-encoded string into a Python object.
  • 27. Python JSON dict object list, tuple array str string int, long, float number True true False false None null