Does formatting change JSON values?
Formatting changes whitespace only. Strings, numbers, booleans, null values, object members, and array order remain the same after parsing and serialization.
Should I use two spaces or four spaces?
Both are valid. Two spaces creates a smaller, commonly used output; four spaces can be easier to scan. Follow the convention of the project receiving the JSON.
What does Compact do?
Compact serializes the parsed value without indentation or line breaks, reducing unnecessary whitespace for transport or storage. It is also commonly called JSON minification.
Why can valid-looking JavaScript fail as JSON?
JSON is stricter than JavaScript object syntax: property names and strings need double quotes, comments are not allowed, and trailing commas, NaN, Infinity, and undefined are invalid.