Files
2nd/10_Wiki/Topic_JavaScript/JavaScript_JSON_Syntax.md
T
koriweb 9609c04755 docs(10_Wiki): W3Schools 위키화 — HTML/CSS/JavaScript(core)
W3Schools 튜토리얼을 P-Reinforce v3.1 포맷으로 위키화(영어 본문, 한/영 섹션 헤더).
- Topic_HTML: 59문서 (튜토리얼+예제, 레퍼런스/메타 제외)
- Topic_CSS: 190문서 (메인 + Advanced/Flexbox/Grid/RWD 전체)
- Topic_JavaScript: 120문서 (코어 언어; Temporal/DOM상세/BOM/WebAPI/AJAX/jQuery/Graphics 등은 후속)
각 폴더 00_INDEX.md(MOC) 포함. 코드 verbatim, 미확인분은 "Not found in source" 표기.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 19:21:18 +09:00

143 lines
6.3 KiB
Markdown

---
id: json-syntax
title: "JSON Syntax"
category: "Frontend"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["JSON syntax", "JSON rules", "name/value pairs", "JSON keys", "JSON files"]
duplicate_of: ""
source_trust_level: "B"
confidence_score: 0.89
created_at: 2026-06-23
updated_at: 2026-06-23
review_reason: ""
merge_history: []
tags: ["javascript", "js", "web", "frontend", "w3schools", "json", "syntax"]
raw_sources: ["https://www.w3schools.com/js/js_json_syntax.asp"]
applied_in: []
github_commit: ""
---
# [[JSON Syntax]]
## 🎯 한 줄 통찰 (One-line insight)
JSON syntax is derived from JavaScript object notation — name/value pairs separated by commas, objects in curly braces, arrays in square brackets — but it is stricter than JavaScript: keys and string values must always use double quotes. [S1]
## 🧠 핵심 개념 (Core concepts)
- **Four syntax rules** — data is in name/value pairs; data is separated by commas; curly braces hold objects; square brackets hold arrays. [S1]
- **JSON keys must be strings in double quotes** — `{"name":"John"}`, whereas JavaScript keys can be strings, numbers, or identifier names (`{name:"John"}`). [S1]
- **JSON string values require double quotes** — `{"name":"John"}`; JavaScript allows double or single quotes (`{name:'John'}`). [S1]
- **JSON is almost identical to JavaScript objects** — and JavaScript arrays can also be written as JSON. [S1]
- **File facts** — the file type for JSON files is `.json`; the MIME type for JSON text is `application/json`. [S1]
## 🧩 추출된 패턴 (Extracted patterns)
- **Name/value (key/value) pair** — a field name in double quotes, a colon, then a value: `"name":"John"`. [S1]
- **Stricter-than-JS rule** — JSON is a subset: it forbids the looser key/quote forms JavaScript allows. [S1]
- **Object access patterns carry over** — a JavaScript object can be read/modified via dot or bracket notation. [S1]
## 📖 세부 내용 (Details)
**JSON syntax rules**
JSON syntax is derived from JavaScript object notation syntax: data is in name/value pairs; data is separated by commas; curly braces hold objects; square brackets hold arrays. [S1]
**JSON data — a name and a value**
JSON data is written as name/value pairs (aka key/value pairs). A name/value pair consists of a field name (in double quotes), followed by a colon, followed by a value: [S1]
```json
"name":"John"
```
JSON names require double quotes. [S1]
**JSON evaluates to JavaScript objects**
The JSON format is almost identical to JavaScript objects. In JSON, keys must be strings, written with double quotes — JSON: [S1]
```json
{"name":"John"}
```
In JavaScript, keys can be strings, numbers, or identifier names — JavaScript: [S1]
```javascript
{name:"John"}
```
**JSON values**
In JSON, values must be one of the following data types: a string, a number, an object, an array, a boolean, or null. In JavaScript, values can be all of the above, plus any other valid JavaScript expression, including a function, a date, or undefined. [S1]
In JSON, string values must be written with double quotes — JSON: [S1]
```json
{"name":"John"}
```
In JavaScript, you can write string values with double or single quotes — JavaScript: [S1]
```javascript
{name:'John'}
```
**JavaScript objects**
With JavaScript you can create an object and assign data to it: [S1]
```javascript
person = {name:"John", age:31, city:"New York"};
```
You can access a JavaScript object like this: [S1]
```javascript
// returns John
person.name;
```
It can also be accessed like this: [S1]
```javascript
// returns John
person["name"];
```
Data can be modified like this: [S1]
```javascript
person.name = "Gilbert";
```
It can also be modified like this: [S1]
```javascript
person["name"] = "Gilbert";
```
You will learn how to convert JavaScript objects into JSON later in this tutorial. [S1]
**JavaScript arrays as JSON**
The same way JavaScript objects can be written as JSON, JavaScript arrays can also be written as JSON. You will learn more about objects and arrays later in this tutorial. [S1]
**JSON files**
The file type for JSON files is `.json`. The MIME type for JSON text is `application/json`. [S1]
## 🛠️ 적용 사례 (Applied in summary)
The applied examples on the page are object creation, access (dot and bracket), and modification (dot and bracket) on a `person` object. No external project/commit applications found in the source.
## 💻 코드 패턴 (Code patterns)
Create, access, and modify a JavaScript object:
```javascript
person = {name:"John", age:31, city:"New York"};
person.name; // returns John
person["name"]; // returns John
person.name = "Gilbert";
person["name"] = "Gilbert";
```
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
JSON vs JavaScript object literals — JSON is the stricter subset: [S1]
- **Keys** — JSON requires string keys in double quotes; JavaScript allows strings, numbers, or identifier names.
- **String values** — JSON requires double quotes; JavaScript allows double or single quotes.
- **Value types** — JSON values must be string, number, object, array, boolean, or null; JavaScript additionally allows functions, dates, undefined, and any valid JS expression.
- **When to use which** — use JSON's stricter form for any data meant to be transported or stored as text; use full JS object syntax for in-program objects.
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
No contradictions found in the source.
## ✅ 검증 상태 및 신뢰도
- **상태:** draft
- **검증 단계:** conceptual (실제 적용 사례 발견 시 applied/validated로 승격 가능)
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
- **신뢰 점수:** 0.89
- **중복 검사 결과:** 신규 생성 (New discovery)
## 🔗 지식 그래프 (Knowledge Graph)
- **상위/루트:** [[JavaScript Tutorial]]
- **관련 개념:** [[JavaScript JSON]], [[JavaScript JSON Data Types]], [[JavaScript JSON Objects]], [[JavaScript JSON Arrays]]
- **참조 맥락:** The rules referenced whenever hand-writing or validating a JSON document.
## 📚 출처 (Sources)
- [S1] W3Schools — JSON Syntax — https://www.w3schools.com/js/js_json_syntax.asp
## 📝 변경 이력 (Change history)
- 2026-06-23: Initial draft synthesized from the W3Schools "JSON Syntax" page (Astra wiki-curation, P-Reinforce v3.1 format).