How to store a javascript function in JSON

I’d recommend this approach:

Store arguments and the body in your json:

{"function":{"arguments":"a,b,c","body":"return a*b+c;"}}

Now parse json and instantiate the function:

var f = new Function(function.arguments, function.body);

I think it’s save

Leave a Comment