What JSON escaping is (and when you need it)
A JSON string is a sequence of characters wrapped in double quotes. Because the double quote and the backslash have special meaning, and because control characters like newline and tab cannot appear literally, JSON defines escape sequences: \" for a quote, \\ for a backslash, \n for a newline, \t for a tab, \r for a carriage return, and \uXXXX for arbitrary code points. Escaping is the act of rewriting raw text so every reserved character is replaced by its escape sequence and the whole thing is quoted, producing a value that is legal wherever a JSON string is expected.
You reach for escaping whenever text has to survive being embedded inside another layer of syntax. The classic case is putting a JSON payload inside source code — a string constant in JavaScript, Python, Go, or a test fixture — where the surrounding quotes and any inner quotes would otherwise collide. It also comes up when nesting JSON inside JSON (a stringified value in an API field), when writing a JSON blob into an environment variable or a YAML/HCL field, and when a structured log line carries a message that itself contains quotes and line breaks.
The opposite problem — reading an escaped string and wanting the real content back — is just as common. A log aggregator shows you "{\"error\":\"timeout\"}" and you want the actual object; a config file stores an escaped blob you need to inspect. That is unescaping, and doing it by hand is exactly where mistakes creep in.