gf3 / sandbox

A nifty JavaScript sandbox for Node.js
ISC License
844 stars 123 forks source link

Returning objects is currently not possible #34

Open chaser92 opened 9 years ago

chaser92 commented 9 years ago

When returning a result object from shovel.js, you're using util.inspect - however, an object passed this way will not be usable on the other side (after JSON.parse, it will be a string that can't be turned back to a JSON, unless one uses eval()). Omitting util.inspect would be enough for this to work as JSON.stringify works recursively.

rfn01 commented 8 years ago

It does seem that JSON.stringify() would be nicer. Is there a reason to stick with util.inspect() here? (Asked with humility, as I'm pretty new to node.js.)

soichih commented 7 years ago

I had to use eval() because of this..

I believe the way I am using Sandbox is such that, running eval() on output.result should be safe.. but this gives me a bit of heebie jeebies.. It would be nice if I could just use JSON.parse directly.