Return-Path: X-Original-To: apmail-couchdb-dev-archive@www.apache.org Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BC694C07D for ; Wed, 2 May 2012 09:53:14 +0000 (UTC) Received: (qmail 79896 invoked by uid 500); 2 May 2012 09:53:13 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 79827 invoked by uid 500); 2 May 2012 09:53:12 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 79807 invoked by uid 99); 2 May 2012 09:53:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 May 2012 09:53:12 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 May 2012 09:53:11 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 138A942B4B1 for ; Wed, 2 May 2012 09:52:51 +0000 (UTC) Date: Wed, 2 May 2012 09:52:51 +0000 (UTC) From: "James Howe (JIRA)" To: dev@couchdb.apache.org Message-ID: <1820288413.16574.1335952371109.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <259555579.13679.1335891769747.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (COUCHDB-1476) In view map function doc object does not have .constructor defined on any of the contained objects. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/COUCHDB-1476?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13266468#comment-13266468 ] James Howe commented on COUCHDB-1476: ------------------------------------- What's wrong with Array.isArray and typeof v === 'object', or even just JSON.parse to do JSON parsing? Take it up with the library developers if they're using broken context-dependent code. > In view map function doc object does not have .constructor defined on any of the contained objects. > --------------------------------------------------------------------------------------------------- > > Key: COUCHDB-1476 > URL: https://issues.apache.org/jira/browse/COUCHDB-1476 > Project: CouchDB > Issue Type: Bug > Components: JavaScript View Server > Affects Versions: 1.2 > Environment: CouchDB 1.2 Release binary on Windows 2003 > Reporter: Andrew Reslan > Priority: Minor > > I am doing some complex view map processing using external libraries. > These libraries use the following checks when parsing a JSON document: > function _isObject(v) { > return (v !== null && !_isUndefined(v) && v.constructor === Object); > } > function _isArray(v) { > return (v !== null && !_isUndefined(v) && v.constructor === Array); > } > The 'doc' object passed to the mapping function does not appear to have the .constructor property defined, nor on any of the enclosed objects, this causes the JSON processing to fail. > A simple workaround is to stringily the doc object and parse the results back, the fixed document then has the .constructor properties correctly set on all objects > var fixed = JSON.parse(JSON.stringify(doc)); -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira