cURL's --json flag
As cURL was celebrating its 25th birthday, I was reading Daniel Stenberg’s story behind the project, and discovered a neat little feature I hadn’t heard of before: the --json
flag! Daniel even blogged about it when it landed in cURL 7.82.0 last year.
So what’s so cool about it? If you’re like me, you’re used to post some JSON data with the following verbose approach:
curl --data '{"msg": "hello"}' \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
https://example.com
You have to pass the data, and also pass headers to specify the content-type. You can make it slightly shorter with the one-letter flags:
Read more...