Function - parse

parse - deserialises JSON to javascript objects
JavaScript has a built in function for converting JSON strings into JavaScript objects.

var parsed = JSON.parse(json); 

Convert a string into a date:

const text = '{"name":"John", "birth":"1986-12-14", "city":"New York"}'; 
const obj = JSON.parse(text);
obj.birth = new Date(obj.birth);

document.getElementById("demo").innerHTML = obj.name + ", " + obj.birth;



© 2023 Better Solutions Limited. All Rights Reserved. © 2023 Better Solutions Limited TopPrevNext