SlideShare a Scribd company logo
JavaScript Object Notation (JSON) Compiled by  Adnan Sohail Software Engineer  i2c inc.
JSON JSON  (JavaScript Object Notation) is a lightweight data-interchange format.  It is easy for humans to read and write.  It is easy for machines to parse and generate.  It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999.  JSON is a text format that is completely language independent. These properties make JSON an ideal data-interchange language.
Why JSON? Because JSON is lightweight, easy to understand, manipulate and generate, it has almost replaced XML which was used previously as the only data-interchange format.  JSON is preferable because of the following reasons: XML is heavier than JSON  to parse XML, we have to use xPath which is an overhead removed in JSON because JSON is native to JavaScript  XML uses tags to describe user data and tags increase the size of data
JSON Structures JSON is built on two structures: A collection of name/value pairs.  In various languages, this is realized as an  object , record, dictionary, hash table, keyed list, or associative array. An ordered list of values.  In most languages, this is realized as an  array , vector, list, or sequence.
Syntax of JSON Object An  object  is an unordered set of name/value pairs.  An object begins with  {  (left brace)  and ends with  }  (right brace) .  Each name is followed by  :  (colon)   and the name/value pairs are separated by  ,  (comma) .
Syntax of JSON Array An  array  is an ordered collection of values.  An array begins with  [  (left bracket)   and ends with  ]  (right bracket) . Values are separated by  ,  (comma) .
Syntax of JSON A  value  can be a  string  in double quotes, or a  number , or true or false or null, or an  object  or an  array . These structures can be nested. A  string  is a collection of zero or more Unicode characters, wrapped in double quotes, using backslash escapes. A character is represented as a single character string. A string is very much like a C or Java string.
JSON Example { “students” :  [ {“id":1, "name":"Adnan Sohail"}, {“id":2, "name":"Irfan Razzaq"} ] }
XML Example <?xml version=&quot;1.0&quot; ?> <root> <student> <id>1</id> <name>Adnan Sohail</name> </student> <student> <id>2</id> <name>Irfan Razzaq</name> </student> </root>
Validating JSON & JSON Security JavaScript’s built-in method eval() is used to validate a JSON string. Note: Use eval() only when the source is authentic and trusted which means use it only if you are sure that the string passed to it is a valid JSON string When you’ve security risks use var myObject = myJSONtext.parseJSON(); Which is available in  http://www.json.org/json.js   but eval() is faster than parseJSON()
Using JSON APIs JSON strings can be easily generated using JSON APIs available at  http://json.org There are two main classes available in  org.json.*  package org.json.JSONObject org.json.JSONArray Strings can be generating from objects of  JSONObject  or  JSONArray  using their  toString()  methods
Benefits of JSON over XML JSON supports data types like string, integer, boolean etc.  JSON is native data format for JavaScript and therefore it faster for the browser to read and understand.  As JSON contains no tags but data and therefore less data to be transferred between client and the server. So, it’s lighter than XML.  Easy for humans to read and write.
JSON References http://www.xul.fr/en-xml-ajax.html http://www.xul.fr/ajax-javascript-json.html http://json.org/ http://www.json.org/java/

More Related Content

What's hot (20)

PPT
Xml 215-presentation
Manish Chaurasia
 
PDF
PHP Loops and PHP Forms
M.Zalmai Rahmani
 
PDF
Mongodb
Apurva Vyas
 
PPT
Java Collections Framework
Sony India Software Center
 
PPTX
Json
Steve Fort
 
PPT
Css Ppt
Hema Prasanth
 
PPTX
Cascading style sheet
Michael Jhon
 
PPT
Html Ppt
Hema Prasanth
 
PDF
Android Networking
Matteo Bonifazi
 
PPTX
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
Unity Technologies
 
PDF
JavaScript - Chapter 11 - Events
WebStackAcademy
 
PPT
Introduction to XML
yht4ever
 
PPTX
MongoDB - Aggregation Pipeline
Jason Terpko
 
PDF
Elastic Search (엘라스틱서치) 입문
SeungHyun Eom
 
PPTX
Random Forest and KNN is fun
Zhen Li
 
PPT
Setting up your development environment
Nicole Ryan
 
PPTX
A Step Towards Data Orientation
Electronic Arts / DICE
 
PPTX
Html
yugank_gupta
 
PPTX
2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript
pcnmtutorials
 
PPTX
XSLT presentation
Miguel Angel Teheran Garcia
 
Xml 215-presentation
Manish Chaurasia
 
PHP Loops and PHP Forms
M.Zalmai Rahmani
 
Mongodb
Apurva Vyas
 
Java Collections Framework
Sony India Software Center
 
Css Ppt
Hema Prasanth
 
Cascading style sheet
Michael Jhon
 
Html Ppt
Hema Prasanth
 
Android Networking
Matteo Bonifazi
 
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
Unity Technologies
 
JavaScript - Chapter 11 - Events
WebStackAcademy
 
Introduction to XML
yht4ever
 
MongoDB - Aggregation Pipeline
Jason Terpko
 
Elastic Search (엘라스틱서치) 입문
SeungHyun Eom
 
Random Forest and KNN is fun
Zhen Li
 
Setting up your development environment
Nicole Ryan
 
A Step Towards Data Orientation
Electronic Arts / DICE
 
2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript
pcnmtutorials
 
XSLT presentation
Miguel Angel Teheran Garcia
 

Viewers also liked (20)

PPTX
JSON: The Basics
Jeff Fox
 
PDF
Json tutorial
Mohammed Bilal
 
PPTX
JSON and REST
Robert MacLean
 
PPT
JSON - Quick Overview
Signure Technologies
 
PPTX
REST & RESTful Web Services
Halil Burak Cetinkaya
 
PDF
Intoduction to php restful web service
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
REST & RESTful Web Service
Hoan Vu Tran
 
PPT
Understanding REST
Nitin Pande
 
PPTX
Design Beautiful REST + JSON APIs
Stormpath
 
PDF
RESTful web
Alvin Qi
 
PDF
Introduction to RESTful Webservice
Eftakhairul Islam
 
PDF
C++ L02-Conversion+enum+Operators
Mohammad Shaker
 
PPTX
Java script
Abhishek Kesharwani
 
KEY
Inside jQuery (2011)
Kenneth Auchenberg
 
PPT
Ppt Wordpress
Wei Ting Ng
 
ODP
Json Tutorial
Napendra Singh
 
PPTX
Android json parser tutorial – example
Rajat Ghai
 
PDF
Fundamental JQuery
Achmad Solichin
 
PDF
When Ajax Attacks! Web application security fundamentals
Simon Willison
 
PDF
jQuery for beginners
Siva Arunachalam
 
JSON: The Basics
Jeff Fox
 
Json tutorial
Mohammed Bilal
 
JSON and REST
Robert MacLean
 
JSON - Quick Overview
Signure Technologies
 
REST & RESTful Web Services
Halil Burak Cetinkaya
 
Intoduction to php restful web service
baabtra.com - No. 1 supplier of quality freshers
 
REST & RESTful Web Service
Hoan Vu Tran
 
Understanding REST
Nitin Pande
 
Design Beautiful REST + JSON APIs
Stormpath
 
RESTful web
Alvin Qi
 
Introduction to RESTful Webservice
Eftakhairul Islam
 
C++ L02-Conversion+enum+Operators
Mohammad Shaker
 
Java script
Abhishek Kesharwani
 
Inside jQuery (2011)
Kenneth Auchenberg
 
Ppt Wordpress
Wei Ting Ng
 
Json Tutorial
Napendra Singh
 
Android json parser tutorial – example
Rajat Ghai
 
Fundamental JQuery
Achmad Solichin
 
When Ajax Attacks! Web application security fundamentals
Simon Willison
 
jQuery for beginners
Siva Arunachalam
 
Ad

Similar to Java Script Object Notation (JSON) (20)

PPTX
JSON - (English)
Senior Dev
 
PPTX
Json training
Elavarasi Dc
 
PPTX
JSON
Zara Tariq
 
PPTX
All about XML, JSON and related topics..
tinumanueltmt
 
PPTX
json.pptx
Anum Zehra
 
PDF
Intro to JSON
George McKinney
 
PPTX
Unit-2.pptx
AnujSood25
 
PDF
Json
soumya
 
PPT
json.ppt download for free for college project
AmitSharma397241
 
PPT
J s-o-n-120219575328402-3
Ramamohan Chokkam
 
PPTX
1 Json Intro and datatype PRESENTATION.pptx
angelinjeba6
 
PPTX
JSON.pptx
TilakaRt
 
PDF
Basics of JSON (JavaScript Object Notation) with examples
Sanjeev Kumar Jaiswal
 
PPTX
Intro to JSON
Mark Daniel Dacer
 
JSON - (English)
Senior Dev
 
Json training
Elavarasi Dc
 
All about XML, JSON and related topics..
tinumanueltmt
 
json.pptx
Anum Zehra
 
Intro to JSON
George McKinney
 
Unit-2.pptx
AnujSood25
 
Json
soumya
 
json.ppt download for free for college project
AmitSharma397241
 
J s-o-n-120219575328402-3
Ramamohan Chokkam
 
1 Json Intro and datatype PRESENTATION.pptx
angelinjeba6
 
JSON.pptx
TilakaRt
 
Basics of JSON (JavaScript Object Notation) with examples
Sanjeev Kumar Jaiswal
 
Intro to JSON
Mark Daniel Dacer
 
Ad

Recently uploaded (20)

PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
July Patch Tuesday
Ivanti
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
July Patch Tuesday
Ivanti
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Biography of Daniel Podor.pdf
Daniel Podor
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 

Java Script Object Notation (JSON)

  • 1. JavaScript Object Notation (JSON) Compiled by Adnan Sohail Software Engineer i2c inc.
  • 2. JSON JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999. JSON is a text format that is completely language independent. These properties make JSON an ideal data-interchange language.
  • 3. Why JSON? Because JSON is lightweight, easy to understand, manipulate and generate, it has almost replaced XML which was used previously as the only data-interchange format. JSON is preferable because of the following reasons: XML is heavier than JSON to parse XML, we have to use xPath which is an overhead removed in JSON because JSON is native to JavaScript XML uses tags to describe user data and tags increase the size of data
  • 4. JSON Structures JSON is built on two structures: A collection of name/value pairs. In various languages, this is realized as an object , record, dictionary, hash table, keyed list, or associative array. An ordered list of values. In most languages, this is realized as an array , vector, list, or sequence.
  • 5. Syntax of JSON Object An object is an unordered set of name/value pairs. An object begins with {  (left brace) and ends with }  (right brace) . Each name is followed by :  (colon) and the name/value pairs are separated by ,  (comma) .
  • 6. Syntax of JSON Array An array is an ordered collection of values. An array begins with [  (left bracket) and ends with ]  (right bracket) . Values are separated by ,  (comma) .
  • 7. Syntax of JSON A value can be a string in double quotes, or a number , or true or false or null, or an object or an array . These structures can be nested. A string is a collection of zero or more Unicode characters, wrapped in double quotes, using backslash escapes. A character is represented as a single character string. A string is very much like a C or Java string.
  • 8. JSON Example { “students” : [ {“id&quot;:1, &quot;name&quot;:&quot;Adnan Sohail&quot;}, {“id&quot;:2, &quot;name&quot;:&quot;Irfan Razzaq&quot;} ] }
  • 9. XML Example <?xml version=&quot;1.0&quot; ?> <root> <student> <id>1</id> <name>Adnan Sohail</name> </student> <student> <id>2</id> <name>Irfan Razzaq</name> </student> </root>
  • 10. Validating JSON & JSON Security JavaScript’s built-in method eval() is used to validate a JSON string. Note: Use eval() only when the source is authentic and trusted which means use it only if you are sure that the string passed to it is a valid JSON string When you’ve security risks use var myObject = myJSONtext.parseJSON(); Which is available in http://www.json.org/json.js but eval() is faster than parseJSON()
  • 11. Using JSON APIs JSON strings can be easily generated using JSON APIs available at http://json.org There are two main classes available in org.json.* package org.json.JSONObject org.json.JSONArray Strings can be generating from objects of JSONObject or JSONArray using their toString() methods
  • 12. Benefits of JSON over XML JSON supports data types like string, integer, boolean etc. JSON is native data format for JavaScript and therefore it faster for the browser to read and understand. As JSON contains no tags but data and therefore less data to be transferred between client and the server. So, it’s lighter than XML. Easy for humans to read and write.
  • 13. JSON References http://www.xul.fr/en-xml-ajax.html http://www.xul.fr/ajax-javascript-json.html http://json.org/ http://www.json.org/java/