Sorry, I sent the msg without completing it, but the function gets parsed
correctly, but i am not able to execute the function. Not sure why require
should be undefined?


On Thu, Jul 24, 2014 at 9: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");
>
>
>
>
> On Thu, Jul 24, 2014 at 2:58 AM, Ryan Schmidt <[email protected]>
> wrote:
>
>>
>> On Jul 23, 2014, at 6:46 PM, Rohit Harchandani wrote:
>>
>> > Hi, I have just started playing around with node.js for a project. I
>> parsed a JSON object which had a javascript function and when I tried to
>> execute the function on the node.js server, I kept getting this error:
>> > ReferenceError: require is not defined
>> > I am sure i parsed the JSON object correctly to get the function, but
>> not sure how to run this function.
>>
>> The JSON format does not accommodate functions, only data.
>>
>> Perhaps you should show us some code so that we can more easily
>> understand the problem you're encountering.
>>
>> --
>> 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/B5AA737B-3074-4B3C-9551-F1AB89DA6941%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/CAMu3Ni2Pb63uxCUPUFva5o89oWKNV1AMD%2BNxRztmdmvmu5NaRg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to