𝟭𝟬 𝗝𝗦𝗢𝗡 𝗘𝗥𝗥𝗢𝗥𝗦 𝗬𝗢𝗨 𝗪𝗜𝗟𝗟 𝗛𝗜𝗧
JSON seems easy. It is not. It is strict. One wrong character breaks your data.
These 10 errors trip up senior developers.
- Trailing commas: Remove the last comma in lists.
- Single quotes: Use double quotes for keys and values.
- Undefined or NaN: Use null instead.
- Special characters: Escape them with a backslash.
- Mismatched brackets: Use a linter to find them.
- Comments: Remove all comments.
- Wrong types: Validate your data.
- Circular references: Use a replacer function.
- Date objects: Save them as ISO strings.
- Large numbers: Use strings for big IDs.
Syntax errors are easy to fix. Semantic errors are worse. They change your data without warning.
Use Zod or Ajv to validate your API boundaries. This stops data corruption.
Which one ruined your day?
Source: https://dev.to/99tools/10-json-errors-every-developer-hits-and-exactly-how-to-fix-them-39eg