OK, so Jan's full reply there was a near-perfect error message. Informative, useful and a proper explanation. So how do we get "Cannot encode 'undefined' value as JSON" to include a link to a wiki page with Jan's reply on it?

Alan.


Jan Lehnardt wrote:

On 30 Dec 2008, at 10:07, paul jobs wrote:

http://rafb.net/p/oz8VfH95.html
[Tue, 30 Dec 2008 09:04:46 GMT] [info] [<0.134.0>] OS Process Log Message:
function raised exception (Cannot encode 'undefined' value as JSON) with
doc._id bef1111175e1d5052e9c49db546b39db

Your Javascript is using an object member that is not defined. E.g.:

{
  "_id":"XYZ123",
  "_rev":"1BB2BB",
  "field":"value"
}

map: function(doc) {
  emit(doc.name, doc.address);
}

instead, try this:

map: function(doc) {
  if(doc.name && doc.address) {
    emit(doc.name, doc.address);
  }
}
Cheers,
Jan

Reply via email to