Hi Jim, I think you do not have the JSON-Class in Place at this point. Try using parseJSON instead. (according to json2.js - file) greetzs mario Am 01.03.2010 um 23:53 schrieb Jim Garvin: > Hi All, > > I'm trying to do server-side created_at timestamps via CouchDB's > _updates > features, but I'm having trouble creating a new document out of the > JSON > passed in the request body. My app doesn't allow updates to existing > documents, only "inserts". Here's the very simple _updates function: > > function(doc, req) { > var newDoc = JSON.parse(req.body); > newDoc.created_at = new Date(); > return [newDoc, "FML"]; > } > > When I POST a document to the appropriate _updates URL, I get an > error in > the log telling me that JSON is not defined: > > [info] [<0.30422.5>] OS Process :: function raised error: > ReferenceError: > JSON is not defined > > I wasn't able to find much reference on the web aside from: > http://wiki.apache.org/couchdb/How_to_intercept_document_updates_and_perform_additional_server-side_processing > http://www.mikealrogers.com/archives/737 > > In the mikealrogers.com post, the author uses JSON in his function, > but > obviously I'm having problems with that approach. Does anyone know > what a > proper way to convert the body of the POST a javascript object would > be? > (avoiding eval()). Also, taking a step back, is this the right > approach > for setting default values on a new document in CouchDB? > > Thanks, > Jim -- Sourcegarden GmbH HR: B-104357 Steuernummer: 37/167/21214 USt-ID: DE814784953 Geschaeftsfuehrer: Mario Scheliga, Rene Otto Bank: Deutsche Bank, BLZ: 10070024, KTO: 0810929 Schoenhauser Allee 51, 10437 Berlin