Hey,
Sometimes I check HTTP responses with CURL so it would be great to format JSON responses.
There is cool command line JSON parser and you can pipe CURL output to it like that:
curl http://some.endpoint/with-json-response | jq '.'
I’ve wrote useful function called jcurl
that is basically wrapper on that command above:
function jcurl() {
curl "$@" | jq '.'
}
P.S.
Don’t forget to source your (bash|zsh|any)rc
.
Hey. Recently I’ve tried to CURL something like this:
curl 'http://localhost?q[param]=value'
and I got [globbing] bad range in column
error from CURL.
This one is unexpected since I was thinking that using single quotes
do not require any escaping. To find a workaround you can check man curl
and
seek for globbing
.
So the solution is -g
option:
curl -g 'http://localhost?q[param]=value'
P.S.
Sure you can manually escape square brackets but if your url is pretty long it can take some time.