[ 
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

        

Reply via email to