Can I execute script from json file? For example:
helloworld.json
{
"script" : "console.log('helloworld');"
}
I want to run the script in the json file in my html or js file.
Can I execute script from json file? For example:
helloworld.json
{
"script" : "console.log('helloworld');"
}
I want to run the script in the json file in my html or js file.
Point eval to the string to execute it as code
var json = {"script":"console.log('helloworld');"}
eval(json["script"])
Yes, you have to:
eval()
Whether that's a good idea or not though depends on your specific use case.