{
"path": "C:\\Users\\Ada\\file.txt"
}Backslashes must be escaped inside JSON strings.
Escape sequences, Unicode, URLs, embedded JSON strings, and encoding pitfalls when storing or transporting JSON.
The escape sequences you use most often in JSON strings.
{
"path": "C:\\Users\\Ada\\file.txt"
}Backslashes must be escaped inside JSON strings.
{
"html": "<\/script>"
}Some serializers escape `/` defensively in HTML contexts.
{
"log": "first line
second line\r
third line"
}Control characters must be escaped when they appear inside a JSON string.
Common mistakes when JSON crosses system boundaries.
Content-Type: application/json; charset=utf-8Most modern APIs and parsers assume UTF-8.
{
"payload": "{\"event\":\"signup\",\"ok\":true}"
}This is valid, but consumers must decode the outer JSON and then parse the inner string separately.
jq '.payload | fromjson' event.jsonUseful when a system stores JSON inside a string field.
jq -n '{event:"signup",ok:true} | @json'Helpful when generating escaped JSON for embedding in another payload.