@Conrad - yes, i am trying this out on the same node.js server now. but
eventually the goal is to ship the code to a node.js client where the sent
code could run. Earlier I did write it to a file and then 'require' it.
That obviously works. Are there better methods of doing this?

@Ryan - This is a simpler json string example below. This too does not work
for me when i run: recData["runFunction"]();

{"runFunction":"function(){'use strict';\nvar net =
require(\"net\");\n\nconsole.log(\"NET\");\n}"}





On Thu, Jul 24, 2014 at 4:37 PM, Ryan Schmidt <[email protected]>
wrote:

> On Jul 24, 2014, at 11:18 AM, Rohit Harchandani <[email protected]> wrote:
>
> > Hi,
> > This is the code that I am using to parse the JSON string.
> >
> > 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:
> >
> > function() {
> >     require("fs");
>
>
> Could you show us sample json input? It's much easier for us to help you
> if you give us enough information to easily reproduce the problem on our
> own systems.
>
>
>
> --
> 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/DD2646F6-CBFF-475B-A82D-23276268AD72%40ryandesign.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAMu3Ni1e34zRjv63B%2B49TKqzR783WtjaY99y3V7vUjmNTOTM3w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to