Javascript Json Convert Javascript Object to String

Introduction

JSON is JavaScript Object Notation

JSON is used to transfer data using key-value pairs and following a JavaScript oriented Syntax

JSON are lighter than as XML.

JSON is native JavaScript support with ES5

var fred1 = { //w w w  .j  ava2 s  .c o  m
    firstName: "CSS", 
    lastName: "HTML", 
    kind: "Language", 
    name: function() { return this.firstName + " " + this.lastName; } 
};

console.log(fred1);               

let json = JSON.stringify(fred1);
console.log(json);               
console.log(typeof json);        

let obj = JSON.parse(json);
console.log(obj);          
console.log(typeof obj);   



PreviousNext

Related