This site is mobile accessible. Press the "Tap Here" button to use a different font-size.
Smartphone icons created by Freepik - Flaticon
const text = '{"name":"John", "age":"function() {return 30;}", "city":"New York"}'; const obj = JSON.parse(text); // evaluate obj.age obj.age = eval("(" + obj.age + ")"); document.getElementById("demo").innerHTML = obj.name + ", " + obj.age();
You should avoid using functions in JSON, the functions will lose their scope, and you would have to use
to convert them back into functions.