InterviewHubPRO
Section Overview
Q117

Question 117 of 521

Part 3: DOM, Event Flow, Timers & Browser APIs (104 - 173)

22%
JavaScript Internals (521 Qs)•Part 3: DOM, Event Flow, Timers & Browser APIs (104 - 173)

What are the syntax rules of JSON

Below are the list of syntax rules of JSON

  1. The data is in name/value pairs
  2. The data is separated by commas
  3. Curly braces hold objects
  4. Square brackets hold arrays

Practical Code Example

javascript
// JSON Syntax Rules:
// 1. Keys must be double-quoted strings
// 2. Values: string, number, object, array, boolean, null (NO functions or undefined)
// 3. No trailing commas allowed
const validJson = `{
  "title": "Interview Guide",
  "version": 2,
  "isActive": true,
  "tags": ["js", "frontend"]
}`;
JSON.parse(validJson);