incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From km <srikrishnamo...@gmail.com>
Subject Re: parsing JSON in update function
Date Fri, 05 Mar 2010 03:38:22 GMT
Hi,

Native JSON parsing is available in latest browsers like firefox 3.1+ and IE
8 and others.
so check if ur using latest browser versions.
pls visit
http://blog.mozilla.com/webdev/2009/02/12/native-json-in-firefox-31/

If ur  using browsers which dont support native JSON, then u might have to
use  a separate js library  to make it work ; u can also use eval() but its
not safe !

HTH
Krishna
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
On Fri, Mar 5, 2010 at 8:44 AM, Mirko Kiefer <mirko.kiefer@arcor.de> wrote:

> Hi,
> I'm trying to parse a JSON string in an update function but on the PUT
> request CouchDB tells me that "JSON is not defined".
> My update function should do something like this (in the request body is
> the JSON string):
>
> function(doc, req) {
>  if (!doc) {
>    if (req.docId) {
>      doc = { _id : req.docId}
>    };
>    return [null, "error"];
>  }
>  doc.properties = JSON.parse(req.body);
>  return [doc, "success"];
> }
>
> Apparently JSON is not available in SpiderMonkey. Anyone who knows how I
> can still easily parse a JSON string?
>
> Thanks,
> Mirko

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message