couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Davis <paul.joseph.da...@gmail.com>
Subject Re: [VOTE] Apache CouchDB 1.2.0 release, first round
Date Mon, 13 Feb 2012 17:50:40 GMT
I'm really not a fan of this. Rather than simplify the situation it's
adding a whole big set of questions on what format we have in a large
number of API end points. Seems like we should just worry about
documenting how our JSON decoder/encoder works and leave it at that.

Last night while chatting with Brian Mitchell I hit on the idea of
having a compliance test suite for JSON round tripping. There are a
large number of weird edge cases in JSON that most people never think
about. Having some sort of automatically generated table of behaviors
for lots of deserialize/serialize round trips seems like it could
solve most of the issues at hand.

On Mon, Feb 13, 2012 at 9:46 AM, Filipe David Manana
<fdmanana@apache.org> wrote:
> On Mon, Feb 13, 2012 at 10:55 AM, Randall Leeds <randall.leeds@gmail.com> wrote:
>>
>> A very rigorous approach might be to work with the tokenized, but not
>> decoded, JSON so that numeric field values could be passed verbatim. For
>> 1.2 I'd just like to see the integer regression patched.
>
> Catching up on this thread, that seems to be what I had in mind as well.
> The following simple patch would do it:
>
> http://friendpaste.com/1H4zOcciVjajGuYTRyrUUB
>
> For every JSON document coming from the http interface, it doesn't
> decode numbers, only validates them, and have them represented by the
> term {json, RawJsonNumberIoList}  (this term is something already used
> by mochijson2, but not by ejson before).
>
> For JSON coming from the view server, like the 1 coming from a
> validate_doc_update request, we would keep doing as we do now, except
> for map/reduce values where we would use the approach mentioned above.
>
> The above patch is just a quick experiment, I didn't attempt to verify
> all possible scenarios. Only verified that the test suite passes.
>
> With the patch:
>
> $ curl -X PUT http://localhost:5984/test/doc1 -d '{"_id": "doc1",
> "integer": 1, "float": 1.0}'
> {"ok":true,"id":"doc1","rev":"1-67bc2600ba5ce41db1961e410f79a611"}
>
> $ curl http://localhost:5984/test/doc1
> {"_id":"doc1","_rev":"1-67bc2600ba5ce41db1961e410f79a611","integer":1,"float":1.0}
>
> Without (current behaviour):
>
> $ curl -X PUT http://localhost:5984/test/doc1 -d '{"_id": "doc1",
> "integer": 1, "float": 1.0}'
> {"ok":true,"id":"doc1","rev":"1-308b01bbabea74f0cea2af7d0e270fb8"}
>
> $ curl http://localhost:5984/test/doc1
> {"_id":"doc1","_rev":"1-308b01bbabea74f0cea2af7d0e270fb8","integer":1,"float":1}
>
>
>
> --
> Filipe David Manana,
>
> "Reasonable men adapt themselves to the world.
>  Unreasonable men adapt the world to themselves.
>  That's why all progress depends on unreasonable men."

Mime
View raw message