Github user davisp commented on the issue:

    https://github.com/apache/couchdb-couch-mrview/pull/47
  
    I think you misunderstood me about calling JSON_DECODE twice. Once was when 
we parse the POST body and the second is trying to parse the value. Not that 
parse_param is calling it twice.
    
    Second, the worrisome bit to me is that your check for all items being a 
binary seemed wrong to me. The check that we need is "is_json" or 
"is_decoded_json" that is able to discern all possible values between needing 
decoding and not. What bothered me with this approach was I couldn't think of a 
solid way to write that. Yesterday I was contemplating a few variations using 
something like `io_lib:printable_unicode_list/1` or even finally adding a 
function to jiffy for something like `is_valid_json/1`. However neither of 
those seemed quite right and this morning I realized its because its impossible 
to tell that a provided term was decoded from JSON or not, because due to JSON 
you can embed values that could be decoded twice (ie, a string that decodes 
into a string that can be decoded, or an array of integers that decodes into 
what Erlang considers a string that can be decoded).
    
    So I think the best solution to this is to add a parameter to 
parse_params/3 along the lines of "IsDecoded" that is threaded through to the 
parse_json/1 call which determines whether the value should be decoded or not.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to