the IT Hustle
工具实战手册关于
FundamentalsAI辅助2026-03-18•10 min 阅读

JSON: The Lingua Franca of Modern Software

作者: Salty Deprecated Software Engineer

✨ AI 辅助内容

本文由 AI 辅助创作,并经团队审核以确保准确性和质量。所有技术信息和示例均已验证。

If you've ever opened a web page, used a mobile app, called an API, or edited a config file, you've interacted with JSON. You may not have known it, but it was there — quietly shuttling data between systems, keeping the modern internet running.

JSON (JavaScript Object Notation) is the universal language of data exchange in modern software.APIs speak JSON. Configuration files use JSON. Databases store JSON. Log files output JSON. If data moves between two systems in 2026, there's a very good chance it moves as JSON.

This article is for anyone who works near technology — developers, analysts, project managers, operations teams — and wants to understand what JSON is, why it won, and how to work with it without making the mistakes that cost everyone time.

What Is JSON?

JSON is a lightweight text format for storing and transmitting structured data. It was derived from JavaScript but is completely language-independent — every major programming language can read and write JSON.

Here's the simplest possible JSON:

{

"name": "Alice",

"age": 32,

"isActive": true

}

That's it. Curly braces hold objects (key-value pairs). Keys are always strings in double quotes. Values can be strings, numbers, booleans (true/false), null, arrays, or other objects. That's the entire specification. You can learn the complete JSON syntax in five minutes.

Why JSON Won (and XML Lost)

Before JSON, the dominant data exchange format was XML. If you've never had to work with XML, consider yourself fortunate. Here's the same data in both formats:

JSON (54 characters):

{"name":"Alice","age":32,"active":true}

XML (same data — 137 characters):

<user>

<name>Alice</name>

<age>32</age>

<active>true</active>

</user>

JSON won for several reasons:

  • It's smaller. Less bandwidth, faster transfers, cheaper storage. At scale, this matters enormously. An API returning millions of records per day saves significant bandwidth with JSON over XML.
  • It's easier to read. Humans can scan JSON and understand the structure immediately. XML requires mentally filtering out closing tags and attributes.
  • It maps directly to programming constructs. JSON objects are dictionaries/maps. JSON arrays are lists/arrays. Every language already has these data structures built in, so parsing JSON is trivial.
  • It's natively JavaScript. Since the web runs on JavaScript, JSON can be parsed with a single function call: JSON.parse(). No external libraries needed.
  • It has no schema overhead. XML often requires DTDs or XSD schemas. JSON is self-describing — you can figure out the structure just by looking at it.

The Anatomy of JSON: Every Data Type Explained

JSON has exactly six data types. That's it — no dates, no binary, no comments. This extreme simplicity is a feature, not a bug.

1. Strings

Text wrapped in double quotes only. Single quotes are not valid JSON (this is the #1 mistake people make).

"Hello, world" ✅ valid

'Hello, world' ❌ invalid (single quotes)

2. Numbers

Integers or floating-point. No quotes. No special notation for integers vs floats.

42 ✅ integer

3.14 ✅ float

-17 ✅ negative

0x1A ❌ invalid (no hex in JSON)

3. Booleans

true or false — lowercase, no quotes.

true ✅ valid

True ❌ invalid (capital T)

"true" ⚠️ valid but it's a string, not a boolean

4. Null

Represents "no value." Lowercase, no quotes.

null ✅ valid

None ❌ invalid (that's Python)

undefined ❌ invalid (that's JavaScript)

5. Arrays

Ordered lists wrapped in square brackets. Items can be any type, including other arrays or objects.

[1, 2, 3] ✅ array of numbers

["red", "green", "blue"] ✅ array of strings

[1, "two", true, null, [5, 6]] ✅ mixed types (valid but unusual)

6. Objects

Key-value pairs wrapped in curly braces. Keys must be strings. Values can be any type.

{

"user": {

"name": "Alice",

"roles": ["admin", "editor"],

"settings": {

"theme": "dark",

"notifications": true

}

}

}

Nesting objects inside objects is what makes JSON powerful. You can represent arbitrarily complex data structures with just these six types.

Where You'll Encounter JSON in the Real World

REST APIs

The vast majority of web APIs send and receive JSON. When your app fetches data from a server, here's what comes back:

GET /api/users/123 response:

{

"id": 123,

"name": "Alice Chen",

"email": "alice@example.com",

"plan": "premium",

"created_at": "2026-01-15T10:30:00Z"

}

Configuration Files

package.json, tsconfig.json, .eslintrc.json, VS Code settings — JSON is the default format for configuration in the JavaScript/Node ecosystem.

package.json (every Node.js project has one):

{

"name": "my-app",

"version": "1.0.0",

"scripts": {

"start": "next start",

"build": "next build",

"test": "jest"

},

"dependencies": {

"next": "^14.0.0",

"react": "^18.0.0"

}

}

Database Storage

Modern databases like PostgreSQL and MongoDB store JSON natively. PostgreSQL's jsonb column type lets you query inside JSON documents with SQL — combining the flexibility of document databases with the reliability of relational databases.

Structured Logging

Modern logging systems output JSON instead of plain text. This makes logs machine-parseable while still being human-readable:

Plain text log (hard to parse programmatically):

2026-03-15 10:30:15 ERROR [auth] Login failed for user alice@example.com from 192.168.1.1

JSON log (easy to search, filter, aggregate):

{"timestamp":"2026-03-15T10:30:15Z","level":"error",

"service":"auth","message":"Login failed","user":"alice@example.com","ip":"192.168.1.1"}

The 7 Most Common JSON Mistakes

These are the errors I see most often, ranked by frequency. Every developer makes at least one of these regularly.

1. Trailing Commas

JavaScript allows trailing commas. JSON does not. This is the most common JSON syntax error.

❌ {"name": "Alice", "age": 32,} ← trailing comma after 32

✅ {"name": "Alice", "age": 32} ← no trailing comma

2. Single Quotes

JSON requires double quotes for strings. Single quotes are invalid.

❌ {'name': 'Alice'} ← single quotes

✅ {"name": "Alice"} ← double quotes

3. Comments

JSON does not support comments. No //, no /* */, nothing. This is by design — Douglas Crockford (JSON's creator) intentionally excluded comments to prevent people from using JSON as a scripting language.

❌ { // this is a user "name": "Alice" }

✅ { "_comment": "this is a user", "name": "Alice" }

If you need comments in configuration files, consider JSONC (JSON with comments, used by VS Code) or YAML instead.

4. Unquoted Keys

❌ {name: "Alice"} ← unquoted key

✅ {"name": "Alice"} ← quoted key

5. Using undefined

❌ {"value": undefined} ← undefined is JavaScript, not JSON

✅ {"value": null} ← use null instead

6. Newlines in Strings

JSON strings cannot contain literal newlines. Use \n instead.

❌ {"bio": "Line one

Line two"}

✅ {"bio": "Line one\nLine two"}

7. Number Precision

JSON numbers are IEEE 754 floating-point. This means integers larger than 2^53 (9,007,199,254,740,992) lose precision when parsed in JavaScript. If you're working with IDs from databases like Snowflake or Twitter, send them as strings.

⚠️ {"id": 9007199254740993} ← will be parsed as 9007199254740992

✅ {"id": "9007199254740993"} ← string preserves precision

Working with JSON: Essential Operations

Parsing JSON (String to Object)

JavaScript:

const data = JSON.parse('{"name":"Alice"}');

console.log(data.name); // "Alice"

Python:

import json

data = json.loads('{"name":"Alice"}')

print(data["name"]) # "Alice"

Always wrap JSON.parse() in a try/catch. If the JSON is malformed, it throws an error that will crash your application if unhandled.

Stringifying JSON (Object to String)

Compact (for APIs — minimal size):

JSON.stringify(data); // {"name":"Alice","age":32}

Pretty-printed (for humans — readable):

JSON.stringify(data, null, 2); // indented with 2 spaces

The third argument to JSON.stringify() controls indentation. Use 2 for readability. Use no arguments (or 0) for minimum file size.

Command-Line JSON with jq

If you work with APIs from the command line, jq is the essential tool for parsing and manipulating JSON:

Pretty-print API response:

curl -s https://api.example.com/users | jq '.'

Extract specific field:

curl -s https://api.example.com/users | jq '.[].name'

Filter by condition:

curl -s https://api.example.com/users | jq '[.[] | select(.active == true)]'

JSON Variants You Should Know About

  • JSONC — JSON with comments. Used by VS Code, TypeScript (tsconfig.json). Allows // and /* */ comments.
  • JSON5 — A superset of JSON that allows trailing commas, single quotes, comments, unquoted keys, and hex numbers. More human-friendly for config files.
  • NDJSON — Newline-delimited JSON. One JSON object per line, used for streaming and log files. Each line is independently parseable.
  • JSON Schema — A vocabulary for annotating and validating JSON. Lets you define required fields, data types, value ranges, and patterns. Essential for API contracts.

Key Takeaways

  • JSON has 6 types: string, number, boolean, null, array, object. That's the entire language.
  • Double quotes only. No single quotes, no unquoted keys, no trailing commas, no comments.
  • JSON is everywhere: APIs, config files, databases, logs. Understanding it is non-negotiable if you work in tech.
  • Always validate JSON before using it. A missing comma or extra bracket will silently break your application.
  • Use tools to help. Pretty-printers, validators, and formatters save time and prevent errors.

Working with messy JSON? Try our free JSON Formatter — paste any JSON and instantly get it validated, pretty-printed, and syntax-highlighted with error detection. No signup required.

IT
Salty Deprecated Software Engineer

以 The IT Hustle 的编辑笔名写作——25 年以上笔记本维修技师、系统管理员、存储工程师和软件工程师的经验,如今用在 AI 智能体运维上。每篇文章发布前都经过人工审核,详见编辑准则。

我们的工具全部文章关于我们

获取最新资讯

第一时间了解新工具、博客文章和更新动态。无垃圾邮件。

生成专属防幻觉提示词

AI 提示词引擎采用专有技术,生成内置验证和矛盾测试的提示词。

免费试用 3 次 →

公司

  • 关于
  • 实战手册
  • AI 术语表
  • 关于作者
  • 联系我们

产品

  • 工具
  • 价格观察
  • 智能体运维
  • 编程
  • 设计
  • 运维
  • 效率
  • 营销
  • 商务

法律信息

  • 隐私政策
  • 服务条款
  • 免责声明
  • 编辑准则
  • 更正说明

© 2026 Salty Rantz LLC. 版权所有。

为在技术变革中前行的职场人打造。