couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Davis <paul.joseph.da...@gmail.com>
Subject Re: how should I handle JSON parsing in update handler
Date Sat, 18 Dec 2010 18:50:33 GMT
Its JSON.stringify(obj)

On Sat, Dec 18, 2010 at 1:40 PM, Josh803316 <josh803316@gmail.com> wrote:
> Oops I forgot to ask how I encode as well, is it JSON.encode?
>
> On Mon, Dec 13, 2010 at 10:24 AM, Zachary Zolton
> <zachary.zolton@gmail.com>wrote:
>
>> 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 <josh803316@gmail.com> 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];
>> >     }
>> >
>>
>

Mime
View raw message