JSON Best Practices
Naming & Structure
- Use lowerCamelCase for keys consistently
- Prefer stable key names; avoid renaming in breaking ways
- Keep payloads small; avoid deep nesting where possible
Nulls, Missing Fields, Defaults
- Prefer omitting optional fields rather than sending nulls
- Document defaults in your API or schema
Dates, Times, Numbers
- Use ISO 8601 strings for datetimes in UTC (e.g. 2025-01-01T12:00:00Z)
- Use strings for big integers to avoid precision loss
Versioning & Compatibility
- Version APIs in URL or header; avoid breaking changes
- Use additive changes (new fields) for forward compatibility
Validation
- Validate with JSON Schema; enforce types and constraints
- Reject unknown fields when needed for strictness