4
Most read
7
Most read
8
Most read
JavaScript JSON
Prof. Neeraj Bhargava
Kapil Chauhan
Department of Computer Science
School of Engineering & Systems Sciences
MDS University, Ajmer
JavaScript JSON
 JSON is a format for storing and transporting data.
 JSON is often used when data is sent from a server to a
web page.
What is JSON?
 JSON stands for JavaScript Object Notation
 JSON is a lightweight data interchange format
 JSON is "self-describing" and easy to understand
Exchanging Data
 When exchanging data between a browser and a server,
the data can only be text.
 JSON is text, and we can convert any JavaScript object into
JSON, and send JSON to the server.
 We can also convert any JSON received from the server into
JavaScript objects.
 This way we can work with the data as JavaScript objects,
with no complicated parsing and translations.
JSON Syntax Rules
 Data is in name/value pairs
 Data is separated by commas
 Curly braces hold objects
 Square brackets hold arrays
JSON Data - A Name and a Value
 JSON data is written as name/value pairs, just like
JavaScript object properties.
 A name/value pair consists of a field name (in double
quotes), followed by a colon, followed by a value:
 "firstName":"John"
JSON Objects
 JSON objects are written inside curly braces.
 Just like in JavaScript, objects can contain multiple
name/value pairs:
 {"firstName":"John", "lastName":"Doe"}
JSON Arrays
 JSON arrays are written inside square brackets.
 Just like in JavaScript, an array can contain objects:
 "employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]
Converting a JSON Text to a
JavaScript Object
 A common use of JSON is to read data from a web server, and display
the data in a web page.
 For simplicity, this can be demonstrated using a string as input.
 First, create a JavaScript string containing JSON syntax:
var text = '{ "employees" : [' +
'{ "firstName":"John" , "lastName":"Doe" },' +
'{ "firstName":"Anna" , "lastName":"Smith" },' +
'{ "firstName":"Peter" , "lastName":"Jones" } ]}';
 Then, use the JavaScript built-in function JSON.parse() to convert the
string into a JavaScript object:
var obj = JSON.parse(text);
Assignment
 Explain JavaScript JSON with example and describe
following
 Syntax rule
 Exchanging data
 JSON Array

More Related Content

PPTX
Javascript validating form
PDF
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
PPTX
Intro to JSON
PPTX
JSON: The Basics
PDF
CSS Selectors
PPTX
XML, DTD & XSD Overview
Javascript validating form
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
Intro to JSON
JSON: The Basics
CSS Selectors
XML, DTD & XSD Overview

What's hot (20)

PDF
Introduction to JSON
PPT
PDF
CSS3 Media Queries
PPTX
Virtual base class
PPT
Introduction to XML
PPT
PHP - DataType,Variable,Constant,Operators,Array,Include and require
ODP
Datatype in JavaScript
PPTX
Xml dom
PPT
Web Application Introduction
PPTX
Array in c#
PPTX
Css selectors
PPT
JAVA OOP
PDF
JavaScript - Chapter 12 - Document Object Model
PDF
Learn Entity Framework in a day with Code First, Model First and Database First
PDF
Php array
PPTX
CSS - Text Properties
PPTX
Introduction to JSON
CSS3 Media Queries
Virtual base class
Introduction to XML
PHP - DataType,Variable,Constant,Operators,Array,Include and require
Datatype in JavaScript
Xml dom
Web Application Introduction
Array in c#
Css selectors
JAVA OOP
JavaScript - Chapter 12 - Document Object Model
Learn Entity Framework in a day with Code First, Model First and Database First
Php array
CSS - Text Properties
Ad

Similar to java script json (20)

PDF
CS8651 IP Unit 2 pdf regulation -2017 anna university
PPTX
Unit-2.pptx
PDF
Basics of JSON (JavaScript Object Notation) with examples
PPTX
PPTX
1 Json Intro and datatype PRESENTATION.pptx
PPTX
Json training
PPTX
Java script and json
PDF
JSON Learning
PPTX
json.pptx
PPTX
JSON - JavaScript Object Notation
PPTX
JSON.pptx
PPTX
JSON.pptx
PDF
Json tutorial, a beguiner guide
PPTX
unit5_part2.pptx
PPTX
Introduction to JavaScript Object Notation(JSON)
PPTX
JSON - (English)
PPTX
Json
PPTX
JSON & AJAX.pptx
PPTX
JSON-(JavaScript Object Notation)
CS8651 IP Unit 2 pdf regulation -2017 anna university
Unit-2.pptx
Basics of JSON (JavaScript Object Notation) with examples
1 Json Intro and datatype PRESENTATION.pptx
Json training
Java script and json
JSON Learning
json.pptx
JSON - JavaScript Object Notation
JSON.pptx
JSON.pptx
Json tutorial, a beguiner guide
unit5_part2.pptx
Introduction to JavaScript Object Notation(JSON)
JSON - (English)
Json
JSON & AJAX.pptx
JSON-(JavaScript Object Notation)
Ad

More from chauhankapil (20)

PPTX
Gray level transformation
PPTX
Elements of visual perception
PPTX
JSP Client Request
PPTX
Jsp server response
PPTX
Markov decision process
PPTX
RNN basics in deep learning
PPTX
Introduction to generative adversarial networks (GANs)
PPTX
Bayesian probabilistic interference
PPTX
PPTX
Exception handling in java
PPTX
Knowledge acquistion
PPTX
Knowledge based system
PPTX
Introduction of predicate logics
PPTX
Types of inheritance in java
PPTX
Representation of syntax, semantics and Predicate logics
PPTX
Inheritance in java
PPTX
Propositional logic
PPTX
Constructors in java
PPTX
Methods in java
PPT
Circular linked list
Gray level transformation
Elements of visual perception
JSP Client Request
Jsp server response
Markov decision process
RNN basics in deep learning
Introduction to generative adversarial networks (GANs)
Bayesian probabilistic interference
Exception handling in java
Knowledge acquistion
Knowledge based system
Introduction of predicate logics
Types of inheritance in java
Representation of syntax, semantics and Predicate logics
Inheritance in java
Propositional logic
Constructors in java
Methods in java
Circular linked list

Recently uploaded (20)

PPTX
ASME PCC-02 TRAINING -DESKTOP-NLE5HNP.pptx
PPT
Chapter 1 - Introduction to Manufacturing Technology_2.ppt
PDF
Design of Material Handling Equipment Lecture Note
PDF
MLpara ingenieira CIVIL, meca Y AMBIENTAL
PPTX
Module 8- Technological and Communication Skills.pptx
PDF
Java Basics-Introduction and program control
PPTX
Micro1New.ppt.pptx the mai themes of micfrobiology
PDF
UEFA_Embodied_Carbon_Emissions_Football_Infrastructure.pdf
PPTX
Software Engineering and software moduleing
PPTX
MAD Unit - 3 User Interface and Data Management (Diploma IT)
PPTX
Chemical Technological Processes, Feasibility Study and Chemical Process Indu...
PPTX
"Array and Linked List in Data Structures with Types, Operations, Implementat...
PDF
distributed database system" (DDBS) is often used to refer to both the distri...
PDF
VSL-Strand-Post-tensioning-Systems-Technical-Catalogue_2019-01.pdf
PPTX
CN_Unite_1 AI&DS ENGGERING SPPU PUNE UNIVERSITY
PDF
UEFA_Carbon_Footprint_Calculator_Methology_2.0.pdf
PDF
Computer System Architecture 3rd Edition-M Morris Mano.pdf
PDF
Unit I -OPERATING SYSTEMS_SRM_KATTANKULATHUR.pptx.pdf
PPTX
A Brief Introduction to IoT- Smart Objects: The "Things" in IoT
PPTX
Management Information system : MIS-e-Business Systems.pptx
ASME PCC-02 TRAINING -DESKTOP-NLE5HNP.pptx
Chapter 1 - Introduction to Manufacturing Technology_2.ppt
Design of Material Handling Equipment Lecture Note
MLpara ingenieira CIVIL, meca Y AMBIENTAL
Module 8- Technological and Communication Skills.pptx
Java Basics-Introduction and program control
Micro1New.ppt.pptx the mai themes of micfrobiology
UEFA_Embodied_Carbon_Emissions_Football_Infrastructure.pdf
Software Engineering and software moduleing
MAD Unit - 3 User Interface and Data Management (Diploma IT)
Chemical Technological Processes, Feasibility Study and Chemical Process Indu...
"Array and Linked List in Data Structures with Types, Operations, Implementat...
distributed database system" (DDBS) is often used to refer to both the distri...
VSL-Strand-Post-tensioning-Systems-Technical-Catalogue_2019-01.pdf
CN_Unite_1 AI&DS ENGGERING SPPU PUNE UNIVERSITY
UEFA_Carbon_Footprint_Calculator_Methology_2.0.pdf
Computer System Architecture 3rd Edition-M Morris Mano.pdf
Unit I -OPERATING SYSTEMS_SRM_KATTANKULATHUR.pptx.pdf
A Brief Introduction to IoT- Smart Objects: The "Things" in IoT
Management Information system : MIS-e-Business Systems.pptx

java script json

  • 1. JavaScript JSON Prof. Neeraj Bhargava Kapil Chauhan Department of Computer Science School of Engineering & Systems Sciences MDS University, Ajmer
  • 2. JavaScript JSON  JSON is a format for storing and transporting data.  JSON is often used when data is sent from a server to a web page.
  • 3. What is JSON?  JSON stands for JavaScript Object Notation  JSON is a lightweight data interchange format  JSON is "self-describing" and easy to understand
  • 4. Exchanging Data  When exchanging data between a browser and a server, the data can only be text.  JSON is text, and we can convert any JavaScript object into JSON, and send JSON to the server.  We can also convert any JSON received from the server into JavaScript objects.  This way we can work with the data as JavaScript objects, with no complicated parsing and translations.
  • 5. JSON Syntax Rules  Data is in name/value pairs  Data is separated by commas  Curly braces hold objects  Square brackets hold arrays
  • 6. JSON Data - A Name and a Value  JSON data is written as name/value pairs, just like JavaScript object properties.  A name/value pair consists of a field name (in double quotes), followed by a colon, followed by a value:  "firstName":"John"
  • 7. JSON Objects  JSON objects are written inside curly braces.  Just like in JavaScript, objects can contain multiple name/value pairs:  {"firstName":"John", "lastName":"Doe"}
  • 8. JSON Arrays  JSON arrays are written inside square brackets.  Just like in JavaScript, an array can contain objects:  "employees":[ {"firstName":"John", "lastName":"Doe"}, {"firstName":"Anna", "lastName":"Smith"}, {"firstName":"Peter", "lastName":"Jones"} ]
  • 9. Converting a JSON Text to a JavaScript Object  A common use of JSON is to read data from a web server, and display the data in a web page.  For simplicity, this can be demonstrated using a string as input.  First, create a JavaScript string containing JSON syntax: var text = '{ "employees" : [' + '{ "firstName":"John" , "lastName":"Doe" },' + '{ "firstName":"Anna" , "lastName":"Smith" },' + '{ "firstName":"Peter" , "lastName":"Jones" } ]}';  Then, use the JavaScript built-in function JSON.parse() to convert the string into a JavaScript object: var obj = JSON.parse(text);
  • 10. Assignment  Explain JavaScript JSON with example and describe following  Syntax rule  Exchanging data  JSON Array