Answers for "json.pars"

PHP
79

javascript parse json

var jsonPerson = '{"first_name":"billy", "age":23}';
var personObject = JSON.parse(jsonPerson); //parse json string into JS object
Posted by: Guest on July-23-2019
0

json.parse with function

const text =
  '{"name":"John", "age":"function () {return 
  30;}", "city":"New York"}';

  const obj = JSON.parse(text);
obj.age = eval("(" + obj.age + ")");

  
document.getElementById("demo").innerHTML = obj.name + ", " + 
  obj.age();
Posted by: Guest on September-24-2021

Browse Popular Code Answers by Language