Run Javascript function from json Object
Is it possible to put an javascript function inside of an json object and run it. Yoes it is. This gives you the possibility to store data in LocalStorge, SessionStorage, cookie or Endpoint and call the function via new Function methode direct from json object.
by scurrilus
JavaScript
const jsonObject = {
func: "function test() {alert('This is a function from json.')}; test();"
}
let runFunction = new Function('context', jsonObject.func);
runFunction();