SaitechLab IT Solutions

Developer Training Manual | Doc ID: STL-JSON-2024

Module 1: JSON Overview

JSON (JavaScript Object Notation) is the industry standard for data interchange. At SaitechLab, we utilize JSON for all REST API communications and client-server data transfer.

Core Features

Module 2: Developer Pain Points & Constraints

While powerful, JSON has strict syntax rules. Developers must be aware of the following limitations to prevent runtime errors.

Constraint 1: No Comments Allowed

The Issue: Standard JSON does not support comments (// or /* */).

Impact: You cannot leave instructions in configuration files or "comment out" lines for debugging. If a parser encounters a comment, it will throw an error.

Constraint 2: The "Trailing Comma" Error

The Issue: JSON is unforgiving regarding punctuation.

Impact: Leaving a comma after the last item in a list will break the file.

{
  "status": "active",
  "retry": 5,       <!-- ERROR: This comma will crash the parser if it is the last item -->
}

Constraint 3: No Date Type

The Issue: JSON supports Strings, Numbers, Booleans, and Null. It does not have a Date object.

Impact: Dates must be stored as strings (ISO 8601). The receiving system must manually parse the string back into a Date object.

Example: "created_at": "2023-10-25T14:00:00Z"

Constraint 4: Numeric Precision

The Issue: JSON treats all numbers as generic "Numbers" (usually floating point).

Impact: Large 64-bit integers (like Database IDs or Transaction IDs) may lose precision when parsed by JavaScript. Best Practice: Send large IDs as strings.

Module 3: Format Comparison Strategy

Use the following guide to choose the right format for your project requirements.

Feature JSON YAML XML
Primary Use Case APIs & Data Transfer Configuration Files Enterprise Docs
Comments Support ❌ No ✅ Yes ✅ Yes
Syntax Strictness 🔴 High 🟡 Medium 🔴 High
Readability 🟢 Good 🟢 Excellent 🟡 Low (Verbose)

Module 4: Knowledge Check

Complete this short quiz to verify your understanding of JSON constraints.

1. Which of the following will cause a standard JSON parser to fail?

2. How does JSON natively handle Date objects?

3. What is the "Trailing Comma" issue?

4. Why might you prefer YAML over JSON for a configuration file?