incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aalto Jukka <jukka.aa...@insta.fi>
Subject Cannot add JSON-document containing quotes
Date Wed, 28 Mar 2012 10:42:17 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message