SlideShare a Scribd company logo
Json.parse() in JavaScript
JSON.parse() takes a JSON string and transforms it
into a JavaScript object.
Syntax:
JSON.parse( stringValue, [reviver] );
- stringValue JSON-string to parse
- reviver function(key, value), function to
transform the value
const json = ‘{"string":"Hello
Nugget!","number":123456,
"boolean":false,"test":null}’;
let obj = JSON.parse(json);
console.log(obj);
console.log(obj.string);
//Output
{
string: “Hello Nugget!”,
number: 123456,
boolean: false,
null: null
}
Hello Nugget!
// Output
{
string: “Hello Nugget!”,
number: 123456,
boolean: “setting true”,
null: null
}
true
JSON.parse(jsonString, function(key, value) {
// some operation
// return value for the key
return value;
});
Using reviver function:
This function is to modify the result before
returning.
let obj = JSON.parse(json,
(key, value) => {
return key === ‘boolean’ ?
‘setting true’: true
});
console.log(obj);
console.log(obj.boolean);

More Related Content

What's hot (20)

PPTX
An Introduction to WebWorker - 01.26.12
Digiflare
 
PDF
Async js - Nemetschek Presentaion @ HackBulgaria
HackBulgaria
 
PDF
Better react/redux apps using redux-saga
Younes (omar) Meliani
 
PPTX
Javascript this keyword
Pham Huy Tung
 
PDF
JavaScript, TypeScipt and React Native
Mitchell Tilbrook
 
DOCX
Ejercicios
leonharo
 
PDF
Callbacks and control flow in Node js
Thomas Roch
 
PDF
Kotlin wonderland
Jedsada Tiwongvokul
 
PDF
JavaScript promise
eslam_me
 
PDF
The Ring programming language version 1.7 book - Part 85 of 196
Mahmoud Samir Fayed
 
PPTX
Aspdevice - Asp Fast Crud introdution
Adriano Mendes
 
PDF
Async History - javascript
Nishchit Dhanani
 
PPTX
Boot strap.groovy
Vijay Shukla
 
KEY
Engineering JavaScript
Jim Purbrick
 
PDF
JavaSE7 Launch Event: Java7xGroovy
Yasuharu Nakano
 
PDF
Minion pool - a worker pool for nodejs
Marcelo Gornstein
 
PPTX
JS Objects manipulation
City University of Macau
 
PPT
Χρήση Vba για την πρόσβαση σε βάση δεδομένων
Nikos Mpalatsoukas
 
PDF
New feature of async fakeAsync test in angular
Jia Li
 
PPTX
Javascript Execution Context Flow
kang taehun
 
An Introduction to WebWorker - 01.26.12
Digiflare
 
Async js - Nemetschek Presentaion @ HackBulgaria
HackBulgaria
 
Better react/redux apps using redux-saga
Younes (omar) Meliani
 
Javascript this keyword
Pham Huy Tung
 
JavaScript, TypeScipt and React Native
Mitchell Tilbrook
 
Ejercicios
leonharo
 
Callbacks and control flow in Node js
Thomas Roch
 
Kotlin wonderland
Jedsada Tiwongvokul
 
JavaScript promise
eslam_me
 
The Ring programming language version 1.7 book - Part 85 of 196
Mahmoud Samir Fayed
 
Aspdevice - Asp Fast Crud introdution
Adriano Mendes
 
Async History - javascript
Nishchit Dhanani
 
Boot strap.groovy
Vijay Shukla
 
Engineering JavaScript
Jim Purbrick
 
JavaSE7 Launch Event: Java7xGroovy
Yasuharu Nakano
 
Minion pool - a worker pool for nodejs
Marcelo Gornstein
 
JS Objects manipulation
City University of Macau
 
Χρήση Vba για την πρόσβαση σε βάση δεδομένων
Nikos Mpalatsoukas
 
New feature of async fakeAsync test in angular
Jia Li
 
Javascript Execution Context Flow
kang taehun
 

Similar to Json.parse() in JavaScript (20)

PDF
Scala in practice
andyrobinson8
 
PDF
Jason parsing
parallelminder
 
PDF
Javascript: the important bits
Chris Saylor
 
PDF
Let's JavaScript
Paweł Dorofiejczyk
 
PDF
Javascript
Aditya Gaur
 
PDF
front-end dev
Paul Comanici
 
DOC
quick json parser
Rajesh Putta
 
PPTX
ES6 Overview
Bruno Scopelliti
 
PDF
JavaScript Execution Context
Juan Medina
 
PPTX
The JavaScript Programming Language
Mohammed Irfan Shaikh
 
PPTX
javascript function & closure
Hika Maeng
 
PDF
Scala in practice
patforna
 
DOCX
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
priestmanmable
 
PDF
JavaScript OOP Pattern
지수 윤
 
PDF
Writing native bindings to node.js in C++
nsm.nikhil
 
PDF
Stop Making Excuses and Start Testing Your JavaScript
Ryan Anklam
 
PDF
JavaScript Object API
SRINIVAS KOLAPARTHI
 
PDF
JavaScript Fundamentals with Angular and Lodash
Bret Little
 
PDF
Underscore and Backbone Models
Kentucky JavaScript Users Group
 
KEY
jrubykaigi2010-lt-rubeus
Takeshi AKIMA
 
Scala in practice
andyrobinson8
 
Jason parsing
parallelminder
 
Javascript: the important bits
Chris Saylor
 
Let's JavaScript
Paweł Dorofiejczyk
 
Javascript
Aditya Gaur
 
front-end dev
Paul Comanici
 
quick json parser
Rajesh Putta
 
ES6 Overview
Bruno Scopelliti
 
JavaScript Execution Context
Juan Medina
 
The JavaScript Programming Language
Mohammed Irfan Shaikh
 
javascript function & closure
Hika Maeng
 
Scala in practice
patforna
 
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
priestmanmable
 
JavaScript OOP Pattern
지수 윤
 
Writing native bindings to node.js in C++
nsm.nikhil
 
Stop Making Excuses and Start Testing Your JavaScript
Ryan Anklam
 
JavaScript Object API
SRINIVAS KOLAPARTHI
 
JavaScript Fundamentals with Angular and Lodash
Bret Little
 
Underscore and Backbone Models
Kentucky JavaScript Users Group
 
jrubykaigi2010-lt-rubeus
Takeshi AKIMA
 
Ad

More from Ideas2IT Technologies (20)

PDF
Version comaparison in JavaScript
Ideas2IT Technologies
 
PDF
Currying in JavaScript
Ideas2IT Technologies
 
PDF
JS Testing Frameworks
Ideas2IT Technologies
 
PDF
Cool usage of Encoding and Decoding a URI in Javascript
Ideas2IT Technologies
 
PDF
Iterables and Iterators in JavaScript
Ideas2IT Technologies
 
PDF
String comparison in javascript
Ideas2IT Technologies
 
PDF
JavaScript symbols
Ideas2IT Technologies
 
PDF
Bubble sort in Java Script
Ideas2IT Technologies
 
PDF
Performance analysis in merging arrays - JavaScript
Ideas2IT Technologies
 
PDF
Nullish coalescing in JavaScript
Ideas2IT Technologies
 
PDF
Conditionally add keys in JavaScript
Ideas2IT Technologies
 
PDF
What is Big O in JavaScript - Part-1
Ideas2IT Technologies
 
PDF
Variable hoisting in JavaScript
Ideas2IT Technologies
 
PDF
Formidable ES6 spread operator in JavaScript
Ideas2IT Technologies
 
PDF
Logging in JavaScript - Part-5
Ideas2IT Technologies
 
PDF
Logging in JavaScript - Part-4
Ideas2IT Technologies
 
PDF
Logging in JavaScript - Part-3
Ideas2IT Technologies
 
PDF
Logging in JavaScript - part-2
Ideas2IT Technologies
 
PDF
Logging in JavaScript - part-1
Ideas2IT Technologies
 
PDF
Array vs set in JavaScript
Ideas2IT Technologies
 
Version comaparison in JavaScript
Ideas2IT Technologies
 
Currying in JavaScript
Ideas2IT Technologies
 
JS Testing Frameworks
Ideas2IT Technologies
 
Cool usage of Encoding and Decoding a URI in Javascript
Ideas2IT Technologies
 
Iterables and Iterators in JavaScript
Ideas2IT Technologies
 
String comparison in javascript
Ideas2IT Technologies
 
JavaScript symbols
Ideas2IT Technologies
 
Bubble sort in Java Script
Ideas2IT Technologies
 
Performance analysis in merging arrays - JavaScript
Ideas2IT Technologies
 
Nullish coalescing in JavaScript
Ideas2IT Technologies
 
Conditionally add keys in JavaScript
Ideas2IT Technologies
 
What is Big O in JavaScript - Part-1
Ideas2IT Technologies
 
Variable hoisting in JavaScript
Ideas2IT Technologies
 
Formidable ES6 spread operator in JavaScript
Ideas2IT Technologies
 
Logging in JavaScript - Part-5
Ideas2IT Technologies
 
Logging in JavaScript - Part-4
Ideas2IT Technologies
 
Logging in JavaScript - Part-3
Ideas2IT Technologies
 
Logging in JavaScript - part-2
Ideas2IT Technologies
 
Logging in JavaScript - part-1
Ideas2IT Technologies
 
Array vs set in JavaScript
Ideas2IT Technologies
 
Ad

Recently uploaded (20)

PDF
Salesforce Pricing Update 2025: Impact, Strategy & Smart Cost Optimization wi...
GetOnCRM Solutions
 
PDF
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
PPTX
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
PDF
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
PDF
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
PDF
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
PPTX
Explanation about Structures in C language.pptx
Veeral Rathod
 
PPTX
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
PPTX
Role Of Python In Programing Language.pptx
jaykoshti048
 
PDF
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
PDF
Why Are More Businesses Choosing Partners Over Freelancers for Salesforce.pdf
Cymetrix Software
 
PDF
SAP GUI Installation Guide for macOS (iOS) | Connect to SAP Systems on Mac
SAP Vista, an A L T Z E N Company
 
PDF
New Download FL Studio Crack Full Version [Latest 2025]
imang66g
 
PDF
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
PDF
AI Image Enhancer: Revolutionizing Visual Quality”
docmasoom
 
PPTX
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
PDF
SAP GUI Installation Guide for Windows | Step-by-Step Setup for SAP Access
SAP Vista, an A L T Z E N Company
 
PPTX
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
PDF
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
PPTX
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
Salesforce Pricing Update 2025: Impact, Strategy & Smart Cost Optimization wi...
GetOnCRM Solutions
 
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
Adobe Illustrator Crack Full Download (Latest Version 2025) Pre-Activated
imang66g
 
Explanation about Structures in C language.pptx
Veeral Rathod
 
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
Role Of Python In Programing Language.pptx
jaykoshti048
 
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
Why Are More Businesses Choosing Partners Over Freelancers for Salesforce.pdf
Cymetrix Software
 
SAP GUI Installation Guide for macOS (iOS) | Connect to SAP Systems on Mac
SAP Vista, an A L T Z E N Company
 
New Download FL Studio Crack Full Version [Latest 2025]
imang66g
 
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
AI Image Enhancer: Revolutionizing Visual Quality”
docmasoom
 
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
SAP GUI Installation Guide for Windows | Step-by-Step Setup for SAP Access
SAP Vista, an A L T Z E N Company
 
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 

Json.parse() in JavaScript

  • 2. JSON.parse() takes a JSON string and transforms it into a JavaScript object. Syntax: JSON.parse( stringValue, [reviver] ); - stringValue JSON-string to parse - reviver function(key, value), function to transform the value const json = ‘{"string":"Hello Nugget!","number":123456, "boolean":false,"test":null}’; let obj = JSON.parse(json); console.log(obj); console.log(obj.string); //Output { string: “Hello Nugget!”, number: 123456, boolean: false, null: null } Hello Nugget!
  • 3. // Output { string: “Hello Nugget!”, number: 123456, boolean: “setting true”, null: null } true JSON.parse(jsonString, function(key, value) { // some operation // return value for the key return value; }); Using reviver function: This function is to modify the result before returning. let obj = JSON.parse(json, (key, value) => { return key === ‘boolean’ ? ‘setting true’: true }); console.log(obj); console.log(obj.boolean);