GUIDE深度 · Deep dive
Common JSON Syntax Errors
JSON is stricter than JavaScript object literals: keys need double quotes, trailing commas are not allowed and comments are invalid. Most parse errors come from one of these near the reported position.
The top five
Trailing comma: {"a":1,} is invalid.
Single quotes: {'a':1} is invalid.
Comments: // or /* */ are invalid.
Unescaped newlines/quotes inside strings; use \n and \".
BOM or invisible characters copied with the text.
How to debug
Look one or two lines around the reported position; use a formatter/validator to locate it.
Pasting into JSON.parse in the console shows the same error.
FAQ
Why does it work locally but fail online?
The online copy may use JSON5/comments or include a BOM.
Can I use YAML instead?
Yes, but APIs usually require JSON; YAML allows comments but is not JSON.