showing results for - "json parse with function"
Emma
25 May 2020
1
2const text =
3  '{"name":"John", "age":"function () {return 
4  30;}", "city":"New York"}';
5
6  const obj = JSON.parse(text);
7obj.age = eval("(" + obj.age + ")");
8
9  
10document.getElementById("demo").innerHTML = obj.name + ", " + 
11  obj.age();