You're running into shell escape issues: $ curl -X PUT http://127.0.0.1:5984/bing {"ok":true} $ curl -X PUT -H "Content-Type: application/json" http://127.0.0. 1:5984/bing/bob -d '{"key":"va\"lue"}' {"ok":true,"id":"bob","rev":"1-9424043dd7e8f320dc86b53ad024f58e"} $ curl http://127.0.0.1:5984/bing/bob {"_id":"bob","_rev":"1-9424043dd7e8f320dc86b53ad024f58e","key":"va\"lue"}
On Wed, Mar 28, 2012 at 5:42 AM, Aalto Jukka <[email protected]> wrote: > Hi, > > I cannot add JSON-document containing quotes. Below is an example where I use > Curl to add JSON-documents. > When I add {"key" : "va\"lue"} JSON document, it seems that operation > succeeds but there is an error in the log. > > ------------- > Versions: > -------------- > Couchdb version 1.1.0 > SUSE Linux Enterprise Server 11 SP1 (x86_64) > > -------------------------------- > Commandline example > -------------------------------- > # Create database > user@server:/> curl -X PUT http://127.0.0.1:5984/test/ > {"ok":true} > > # Add JSON document id=1 without quote > user@server:/> curl -X PUT http://127.0.0.1:5984/test/1/ -H "Content-Type: > application/json" -d '{"key" : "value"}' > {"ok":true,"id":"1","rev":"1-59414e77c768bc202142ac82c2f129de"} > > # Get JSON document id=1 > user@server:/> curl -X GET http://127.0.0.1:5984/test/1/ > {"_id":"1","_rev":"1-59414e77c768bc202142ac82c2f129de","key":"value"} > > # Add JSON document id=2 with quote -> server error > user@server:/> curl -X PUT http://127.0.0.1:5984/test/2/ -H "Content-Type: > application/json" -d '{"key" : "va\"lue"}' > {"ok":true,"id":"2","rev":"1-9424043dd7e8f320dc86b53ad024f58e"} > > # Try to get JSON document id=2 > user@server:/> curl -X GET http://127.0.0.1:5984/test/2/ > {"error":"unknown_error","reason":"undef"} > > -------------------------------------------------------------------------- > couchdb.log > -------------------------------------------------------------------------- > [Wed, 28 Mar 2012 09:40:27 GMT] [info] [<0.14316.1189>] 127.0.0.1 - - 'PUT' > /test/ 201 > [Wed, 28 Mar 2012 09:40:38 GMT] [info] [<0.14426.1189>] 127.0.0.1 - - 'PUT' > /test/1/ 201 > [Wed, 28 Mar 2012 09:40:51 GMT] [info] [<0.14542.1189>] 127.0.0.1 - - 'GET' > /test/1/ 200 > [Wed, 28 Mar 2012 09:41:13 GMT] [info] [<0.14749.1189>] 127.0.0.1 - - 'PUT' > /test/2/ 201 > [Wed, 28 Mar 2012 09:41:24 GMT] [error] [<0.14851.1189>] Uncaught error in > HTTP request: {error,undef} > [Wed, 28 Mar 2012 09:41:24 GMT] [info] [<0.14851.1189>] Stacktrace: > [{xmerl_ucs,from_utf8,[<<"va\"lue">>]}, > {mochijson2,json_encode_string,2}, > {mochijson2, > '-json_encode_proplist/2-fun-0-',3}, > {lists,foldl,3}, > {mochijson2,json_encode_proplist,2}, > {couch_httpd,send_json,4}, > {couch_httpd_db,do_db_req,2}, > {couch_httpd,handle_request_int,5}] > [Wed, 28 Mar 2012 09:41:24 GMT] [info] [<0.14851.1189>] 127.0.0.1 - - 'GET' > /test/2/ 500 > > - Jukka
