I think that there's a syntax error in the source to the function you're
passing in, because your code works for me.
var recDataString = JSON.stringify({
function: 'function () {var fs = require("fs"); console.log("did stuff") }'
});
var recData = JSON.parse(recDataString, function (key,value) {
if (value && (typeof value === 'string') && value.indexOf("function") ===
0) {
var jsFunc = new Function('return ' + value)();
return jsFunc;
}
return value;
});
> recData
{ function: [Function] }
> recData.function();
did stuff
undefined
And:
var recData = JSON.parse(recDataString, function (key, value) {
if (value && (typeof value === 'string') && value.indexOf("function") ===
0) {
var jsFunc = new Function('return ' + value)();
return jsFunc;
}
return value;
});
console.log( "Type: " + typeof recData["runFunction"] )
runFunction in the json is a function which is something like this:
But "runFunction".indexOf("function") !== 0, so it'll never be inflated.
-- Rebecca
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/etPan.53d1833f.2ae8944a.683a%40sierra.manhunt.local.
For more options, visit https://groups.google.com/d/optout.