JSON error messages explained
Paste the error you got into your search bar and you probably landed on one of these. Each page shows the exact wording across browsers and Python versions, the usual causes with code to fix them, and an editor that underlines the broken line in your own JSON.
JavaScript
- Unexpected token '<', "<!DOCTYPE "... is not valid JSONThe first character JSON.parse saw was <, and no JSON document can start with that.
- Unexpected end of JSON inputThe parser reached the end of the text while it was still expecting more, either because there was no text at all or because it stopped partway through an object or array.
- "[object Object]" is not valid JSONJSON.parse only accepts a string.
- "undefined" is not valid JSONJSON.parse received undefined, turned it into the text "undefined" and failed on the u.
- Expected double-quoted property name in JSONAfter a comma the parser expects another "key": value pair.
- Expected property name or '}' in JSONRight after a { the parser needs either a double-quoted key or a closing }.
- Unexpected non-whitespace character after JSONThe parser read one complete JSON value and then found more text after it.
- Bad control character in string literal in JSONJSON strings can't contain raw control characters such as a real line break or tab.
Python
- JSONDecodeError: Expecting value: line 1 column 1 (char 0)Python's json module looked for a JSON value at the very first character and found nothing usable.
- Expecting property name enclosed in double quotesPython's json module found something other than a double-quoted key where a key should start.
- JSONDecodeError: Extra dataPython decoded one complete JSON value and then found more text after it.