JSON (JavaScript Object Notation) follows strict syntax rules. If your data doesn't adhere to these, parsers will fail.
The Golden Rules of JSON
- Double Quotes Only: Keys and string values must be enclosed in double quotes (
"). Single quotes (') are invalid. - No Trailing Commas: You cannot have a comma after the last item in an array or object.
- Case Sensitivity:
true,false, andnullmust be lowercase. - Valid Numbers: Leading zeros are not allowed (e.g.,
05is invalid, use5).
Common "JSON Lint" Error:
Unexpected token ' in JSON at position...
This usually means you used single quotes instead of double quotes.
How to Use the JSONFriend Linter
Our online editor acts as a real-time JSON Lint tool. As you type or paste:
- The editor performs a static analysis of your code.
- Syntax errors are highlighted immediately in the gutter.
- Formatting tools can automatically fix indentation, making errors easier to spot.