[clouchdb-devel] Problems with document-to-json

Christian Haselbach ch at mr-co.de
Fri Jun 13 22:11:11 UTC 2008


Hello,

I'm just experimenting with clouchdb. As noted in the news section of
clouchdb, CouchDB's view API changed in 0.8. I wanted to adjust the
corresponding methods in clouchdb. This worked fine for the ad-hoc view,
but in the create view I ran into a problem with document-to-json. I
think it does not handle nested maps correctly, or at least not like
cl-json.

For example this create document statement:
(create-document '((name . "Hi there2")
                   (content . ((foo . "bar") (bla . "fasel")))
                   (nested . ((foo . ((bla . ((fasel . "zort"))))))))
                 :id "hithere2")
will result in this document:
{"_id":"hithere2","_rev":"1840089990",
  "NAME":"Hi there2",
  "CONTENT":{"FOO":"bar","BLA":"fasel"},
  "NESTED":[["FOO",["BLA",["FASEL"]]]]}

CONTENT looks fine, but NESTED not so much.

Observe the following differencs in document-to-json an
encode-json-to-string:
(json:encode-json-to-string '((foo . ((bar . baz)))))
"{\"foo\":{\"bar\":\"baz\"}}"
(clouchdb::document-to-json '((foo . ((bar . baz)))))
"[[\"FOO\",[\"BAR\",]]]"

Is this intendend?

Thanks and regards,
Christian



More information about the clouchdb-devel mailing list