NadirTools

Strict JSON Syntax and Formatting Rules

1 min read

Understand the strict structural requirements of JSON to avoid common parsing errors.

The Rules of JSON

JavaScript Object Notation (JSON) is a lightweight data-interchange format. While it is easy for humans to read, strict rules apply to its syntax:

1. **Double Quotes Only**: All keys and string values must be enclosed in double quotes (`"`). Single quotes (`'`) are invalid.

2. **No Trailing Commas**: Unlike standard JavaScript objects, JSON does not allow a comma after the final property in an object or array.

3. **Data Types**: Allowed data types are String, Number, Object (JSON object), Array, Boolean, and Null. Functions and undefined are not permitted.

Example of Valid JSON

json
{
  "name": "NadirTools",
  "active": true,
  "metrics": [1, 2, 3]
}