You can use the global JSON object for this:

function(doc, req) {
     var active_test = JSON.parse(req.body);

     doc['active_test'] = active_test;
     return [doc, req.body];
    }

Cheers,
Zach

On Sat, Dec 11, 2010 at 1:06 PM, Josh803316 <[email protected]> wrote:
> If I send a json string to my update handler as part of req.body what is the
> best way to convert it to a JSON object?
>
> Do the CouchDb js libraries already include a built in JSON parser or do I
> have to use eval?
>
> "active_test" : function(doc, req) {
>      var active_test = eval('(' + req.body + ')');
>
>      doc['active_test'] = active_test;
>      return [doc, req.body];
>     }
>

Reply via email to