{
"color": "red",
"count": 2
}A JSON string is not the characters you see. A quote has to be escaped, a newline has to become \n, and a backslash has to be doubled. JSON escape takes the text you paste and returns one JSON string literal, including the surrounding quotes.
The two characters a quote and a newline, written between a and b as a" then a line break then b, escape to the literal "a\"\nb". That is a quote, the letter a, a backslash, a quote, a backslash, n, the letter b, and a closing quote. JSON unescape of that literal returns the original two lines. The round trip is the check that the escaping is reversible.
This is not minifying a document. The minifier parses JSON and writes it compactly. Escape treats the whole paste as raw text, even if the paste happens to look like JSON. The sample object {"color":"red","count":2} escaped as text becomes a quoted string whose contents are the escaped braces and quotes.
The characters a, a double quote, a newline, and b.
The JSON string literal "a\"\nb". Unescape returns the original two lines.
The escape is JSON.stringify of the text, so the literal is legal to drop into a string field without hand-counting backslashes.
No. Every character is data. A brace is a brace inside the string, not the start of an object.
Yes. Escaping a" and a newline and then unescaping returns the same text.
It is doubled, which is the JSON rule, so a Windows path survives.
No. Space stays a space inside the JSON string. Percent-encoding is the URL encoder.
Because escape does not parse. It quotes. The minifier and the formatter parse.