On Jan 29, 2013, at 9:04 AM, Thomas Bock <[email protected]> wrote:
> curl -X PUT --data '{"a": "\r"}' --header "Content-Type: application/json"
> http://localhost:5984/r_test/ab7a
I think JSON does not allow literal returns/newlines (or other control
characters) inside strings; they have to be backslash-escaped. It’s hard to
follow exactly what’s going on through all the levels of quoting and unquoting
that happen in the shell and in the Erlang output, but I think you haven’t
escaped that \r enough — it probably needs to be "\\\r".
FYI, as a side note, I’ve found the ‘httpie’[1] utility a lifesaver when
talking to CouchDB (and other REST/JSON APIs) from the command line. It’s like
a souped-up curl with a much clearer syntax for setting query parameters, and
the ability to easily specify a JSON body. For example, I can run your same
command as:
http PUT :5984/r_test/ab7a a='\r’
—Jens
[1]: https://github.com/jkbr/httpie