For quick testing, I use Postman or Insomnia to craft the request first, then copy the curl command.
But if you’re stuck with post json curl, try this:
```bash
curl -H "Content-Type: application/json" -d "$(jq -c . <<< '{"key":"value"}')" http://example.com/api
```
`jq` validates the JSON, and `<<<` avoids file clutter.
But if you’re stuck with post json curl, try this:
```bash
curl -H "Content-Type: application/json" -d "$(jq -c . <<< '{"key":"value"}')" http://example.com/api
```
`jq` validates the JSON, and `<<<` avoids file clutter.
