couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Bock" <thsteinb...@web.de>
Subject Re: lexical error: invalid character inside string
Date Wed, 30 Jan 2013 07:47:14 GMT

Thank you for the answer!

> >  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-

 But the curl line works; and in futon I also can type in a simple \r

> 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".

 This ("\\\r") don't work; "\\r" works. Since \r is the end sign
of a gauge (and it don't accept any other) for a measurement value query
I need a reliable way.

>
> 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

Mime
View raw message