I am getting json from and API via curl like so:
$ curl -H 'Accept: application/json' http://127.0.0.1:8000/snippets/2/
{"id":2,"title":"","code":"print \"hello, work\"\n","linenos":false,"language":"python","style":"friendly"}
… and all is well. But I want to format the json output as a string that will be acceptable to use as form data for a POST request. So I added | sed -e's/\"/\'/g'
to the above curl command but the shell is expecting me to provide another quote. See …
$ curl -H 'Accept: application/json' http://127.0.0.1:8000/snippets/2/ | sed -e's/\"/\'/g'
>
>
>
> '
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0sed: -e expression #1, char 8: unterminated `s' command
100 107 100 107 0 0 13375 0 --:--:-- --:--:-- --:--:-- 13375
(23) Failed writing body
I was hoping to turn all the "
's in the output to '
's.
Update: Thank for pointing out answer How to escape single quotes within single quoted strings? but I do not think changing my command line to ...
$ curl -H 'Accept: application/json' http://127.0.0.1:8000/snippets/2/ | sed -e's/'"'"'/"'"'"/g'
... will solve my problem ... I'll try it. Tried it and got same error.