You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by Damien Katz <da...@apache.org> on 2008/08/27 22:17:09 UTC
json term changes
I've checked in the json_term_changes branch today. Big thanks to
Chris Anderson (jchris) as this is mostly his work.
The new term format is:
json_string() = binary()
json_number() = integer() | float()
json_array() = [json_term()]
json_object() = { [{json_string(), json_term()}] }
json_term() = json_string() | json_number() | json_array() |
json_object()
The main purpose with these changes are:
1. Less memory. The new json terms use binary strings instead of list
strings, this makes each JSON string is now about 1/8 the size in
memory.
2. To use the "blessed" term format. Among Erlang principals, this
format has been decided upon as standard term format for representing
JSON in Erlang. The means we should benefit from a wider range of
Erlang Json libraries sharing the same format, and much faster parsing
as there is now a proposal to create Erlang built-in functions for
parsing and producing json using this term format.
Everything should continue work identically for clients, there are no
semantic changes here. However, this does break existing databases at
the file level, so you'll have to dump, upgrade and recreate your
existing databases.
These changes individually are mostly minor, but they are numerous and
touch a lot of the code base. I'd appreciate any time people can spend
looking at the changes and testing the code. Comments and criticisms
welcome. Hopefully we can get this merged into trunk quickly.
-Damien
Re: json term changes
Posted by Damien Katz <da...@apache.org>.
Thanks for finding these Michael!
-Damien
On Aug 27, 2008, at 11:43 PM, Michael Hendricks wrote:
> On Wed, Aug 27, 2008 at 04:17:09PM -0400, Damien Katz wrote:
>> I've checked in the json_term_changes branch today. Big thanks to
>> Chris
>> Anderson (jchris) as this is mostly his work.
>
> Running the json_term_changes branch, GET http://localhost:5984/
> returns:
>
> {"couchdb":[87,101,108,99,111,109,101],"version":
> [48,46,57,46,48,97,54,56,57,55,48,55,45,105,110,99,117,98,97,116,105,110,103
> ]}
>
>
> Another regression that I noticed is that POSTing a single document to
> _bulk_docs does not create a unique ID for the document. For example:
>
> ---- Request ----
> POST http://localhost:5984/net-couchdb-11383-21716/_bulk_docs
> Accept: application/json
>
> {"docs":[{"foo":"bar"}]}
>
> ---- Response ----
> HTTP/1.1 201 Created
> Cache-Control: must-revalidate
> Date: Thu, 28 Aug 2008 03:39:07 GMT
> Server: CouchDB/0.9.0a689707-incubating (Erlang OTP/R12B)
> Content-Length: 53
> Content-Type: application/json
> Client-Date: Thu, 28 Aug 2008 03:39:07 GMT
> Client-Peer: 127.0.0.1:5984
> Client-Response-Num: 1
>
> {"ok":true,"new_revs":[{"id":"","rev":"1199132587"}]}
>
>
> Notice that the "id" is the blank string.
>
> --
> Michael
Re: json term changes
Posted by Chris Anderson <jc...@grabb.it>.
Michael,
Thanks for finding these regressions.
In writing the JSON format patch, I worked against the current Futon
test-suite. Any regressions we find in the JSON branch are a great
opportunity to increase the test-suite's coverage.
I hope that as we fix behaviors like this, we take the time to add
test-cases so we don't get future regressions.
And... here's another regression fixed and tested:
https://issues.apache.org/jira/browse/COUCHDB-108
Chris
--
Chris Anderson
http://jchris.mfdz.com
Re: json term changes
Posted by Michael Hendricks <mi...@ndrix.org>.
On Wed, Aug 27, 2008 at 04:17:09PM -0400, Damien Katz wrote:
> I've checked in the json_term_changes branch today. Big thanks to Chris
> Anderson (jchris) as this is mostly his work.
Running the json_term_changes branch, GET http://localhost:5984/
returns:
{"couchdb":[87,101,108,99,111,109,101],"version":[48,46,57,46,48,97,54,56,57,55,48,55,45,105,110,99,117,98,97,116,105,110,103]}
Another regression that I noticed is that POSTing a single document to
_bulk_docs does not create a unique ID for the document. For example:
---- Request ----
POST http://localhost:5984/net-couchdb-11383-21716/_bulk_docs
Accept: application/json
{"docs":[{"foo":"bar"}]}
---- Response ----
HTTP/1.1 201 Created
Cache-Control: must-revalidate
Date: Thu, 28 Aug 2008 03:39:07 GMT
Server: CouchDB/0.9.0a689707-incubating (Erlang OTP/R12B)
Content-Length: 53
Content-Type: application/json
Client-Date: Thu, 28 Aug 2008 03:39:07 GMT
Client-Peer: 127.0.0.1:5984
Client-Response-Num: 1
{"ok":true,"new_revs":[{"id":"","rev":"1199132587"}]}
Notice that the "id" is the blank string.
--
Michael