JSON inside a curl command

API docs often show a request body inside a curl command, after -d, --data, --data-raw or --json. Copying the body can bring the flag and the shell's quotes with it. The shell also has its own escapes: inside single quotes, an apostrophe is written as '\'', and inside double quotes, each " is written as \". Neither is valid JSON.

In Chrome and Node.js, JSON.parse says: Unexpected token 'c'

Broken
curl https://api.example.com/users \
  -H 'Content-Type: application/json' \
  -d '{"name": "Ada Lovelace", "note": "It'\''s done"}'
Fixed
{"name": "Ada Lovelace", "note": "It's done"}

Fix it by hand

Keep only what's inside the quotes after the flag, and turn each '\'' back into '.

Open this example in j2n