Answers for "json.parse with function"

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

Code answers related to "Javascript"

Browse Popular Code Answers by Language