TIL that curl supports a --json
flag to send and accept JSON responses since version 7.82.0, which means that the following requests,
sh
'{"name": "morpheus"}' \
curl --data "Content-Type: application/json" \
--header "Accept: application/json" \
--header
--request POST https://example.com/api/users
'{"name": "morpheus"}' \
curl -d "Content-Type: application/json" \
-H "Accept: application/json" \
-H
-X POST https://example.com/api/users
can be further shortened as follows:
sh
'{"name": "morpheus"}' \
curl --json
-X POST https://example.com/api/users
Source: https://glaforge.dev/posts/2023/03/22/curl-s-json-flag/