Strange JSON in CouchDB

I study CouchDB I really love its functionality. However, I am being fooled, and this is the claim that CouchDB communicates via JSON.

Actually, JSON requires that the keys for objects be strings, and possibly even recommended by Damien Katz himself , in order to have views that return objects whose keys are other objects or arrays.

This is confusing since I have not found anywhere where CouchDB uses the JSON option. Moreover, this does not make much sense, for at least two reasons:

  • When are two keys considered equal? For example, I assume that if CouchDB allows keys that are not strings, numbers will be resolved. But then the keys 5and '5'will differ, which is strange, since in Javascript they are considered the same.

  • More importantly, parsing CouchDB output will be more complex since you cannot use the standard JSON parsers available for each language.

Am I just confused about the interpretation of the links above or is CouchDB actually returning non-standard JSON output? And if so, how can you work with it?

+3
source share
3 answers

Do not get confused between the keys of an object and the keys of a couchdb view.

CouchDB , . id - , key value . .

.

$ curl http://127.0.0.1:5984/blog/_design/posts/_view/by_date
{"total_rows":3,"offset":0,"rows":[
{"id":"88e325c07e897f52766340dc17003322","key":[2010,10,13],"value":null},
{"id":"88e325c07e897f52766340dc17002641","key":[2011,4,5],"value":null},
{"id":"88e325c07e897f52766340dc1700233e","key":[2011,4,23],"value":null}
]}
+3

( _id) . ( emit()) JSON. , .

CouchDB. , , :

  • libicu.
  • , ..

, , , , , .

, CouchDB JSON. JSON CouchDB, , .

+5

, .

enter image description here

In the second thought, the keys are part of the operations of the card / reduction, so I have to delve into it.

+1
source

All Articles