String with functions to JSON -


i need turn string:

"{    click : myclickfunction,    render : myrenderfunction }"  

or variation of it,

into :

{    click : myclickfunction,    render : myrenderfunction } 

where myclickfunction , myrenderfunction functions defined else , not strings

try this:

function myclickfunction (test) {    return "foo"; }  function myrenderfunction (test) {     return "bar"; } var mystring = "{click : myclickfunction,render : myrenderfunction}";  var obj=eval("("+mystring+")"); console.log(obj); console.log(obj.click()); console.log(obj.render()); 

Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Website Login Issue developed in magento -

Can the constants be defined inside a model file of a framework in PHP? -