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>
This commit is contained in:
@@ -0,0 +1,128 @@
|
||||
---
|
||||
id: json-objects
|
||||
title: "JSON Objects"
|
||||
category: "Frontend"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["JSON objects", "JSON object literal", "access JSON object", "loop JSON object", "JSON dot bracket notation"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-06-23
|
||||
updated_at: 2026-06-23
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["javascript", "js", "web", "frontend", "w3schools", "json", "objects"]
|
||||
raw_sources: ["https://www.w3schools.com/js/js_json_objects.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[JSON Objects]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A JSON object literal is curly-brace text of key/value pairs; once parsed into a JavaScript object you read its members by dot or bracket notation and iterate them with a for-in loop — but the literal itself is a string format, not "a JSON object." [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **JSON object literals are surrounded by curly braces `{}`** and contain key/value pairs. [S1]
|
||||
- **Keys and values rules** — keys must be strings, and values must be a valid JSON data type. [S1]
|
||||
- **Terminology caution** — it is a common mistake to call a JSON object literal "a JSON object." JSON cannot be an object; JSON is a string format. [S1]
|
||||
- **Two ways to obtain an object** — write a JavaScript object directly from a literal, or parse a JSON string with `JSON.parse()`. [S1]
|
||||
- **Two ways to access members** — dot notation (`myObj.name`) or bracket notation (`myObj["name"]`). [S1]
|
||||
- **Iterate with for-in** — loop over keys, and access each value via `myObj[x]`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Literal → object** — `myObj = {...}` or `myObj = JSON.parse(myJSON)`. [S1]
|
||||
- **Dot vs bracket access** — `myObj.name` equals `myObj["name"]`. [S1]
|
||||
- **For-in over keys** — `for (const x in myObj)` yields keys; index with `myObj[x]` for values. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
**JSON object literals**
|
||||
JSON object literals are surrounded by curly braces `{}`. JSON object literals contains key/value pairs. Keys must be strings, and values must be a valid JSON data type. It is a common mistake to call a JSON object literal "a JSON object." JSON cannot be an object. JSON is a string format. [S1]
|
||||
|
||||
This is a JSON string: [S1]
|
||||
```json
|
||||
{"name":"John", "age":30, "car":null}
|
||||
```
|
||||
|
||||
**Creating a JavaScript object**
|
||||
You can create a JavaScript object directly from a JSON object literal: [S1]
|
||||
```javascript
|
||||
myObj = {"name":"John", "age":30, "car":null};
|
||||
```
|
||||
Normally you create a JavaScript object by parsing a JSON string: [S1]
|
||||
```javascript
|
||||
myObj = JSON.parse(myJSON);
|
||||
```
|
||||
|
||||
**Accessing object values**
|
||||
You can access object values by using dot (`.`) notation: [S1]
|
||||
```javascript
|
||||
x = myObj.name;
|
||||
```
|
||||
You can also access object values by using bracket (`[]`) notation: [S1]
|
||||
```javascript
|
||||
x = myObj["name"];
|
||||
```
|
||||
|
||||
**Looping an object**
|
||||
You can loop through object properties with a for-in loop. Loop printing the keys: [S1]
|
||||
```javascript
|
||||
const myJSON = '{"name":"John", "age":30, "car":null}';
|
||||
const myObj = JSON.parse(myJSON);
|
||||
|
||||
let text = "";
|
||||
for (const x in myObj) {
|
||||
text += x + ", ";
|
||||
}
|
||||
```
|
||||
In a for-in loop, use the bracket notation to access the values: [S1]
|
||||
```javascript
|
||||
const myJSON = '{"name":"John", "age":30, "car":null}';
|
||||
const myObj = JSON.parse(myJSON);
|
||||
|
||||
let text = "";
|
||||
for (const x in myObj) {
|
||||
text += myObj[x] + ", ";
|
||||
}
|
||||
```
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
Applied examples on the page: build `myObj` from a literal and from `JSON.parse()`; read values via dot and bracket notation; and iterate with for-in (keys, then values via `myObj[x]`). No external project/commit applications found in the source.
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Parse then access:
|
||||
```javascript
|
||||
const myObj = JSON.parse('{"name":"John", "age":30, "car":null}');
|
||||
x = myObj.name; // dot notation
|
||||
x = myObj["name"]; // bracket notation
|
||||
```
|
||||
Iterate values:
|
||||
```javascript
|
||||
let text = "";
|
||||
for (const x in myObj) {
|
||||
text += myObj[x] + ", ";
|
||||
}
|
||||
```
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
No contradictions found in the source.
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual (실제 적용 사례 발견 시 applied/validated로 승격 가능)
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[JavaScript Tutorial]]
|
||||
- **관련 개념:** [[JavaScript JSON Arrays]], [[JavaScript JSON Parse]], [[JavaScript JSON Data Types]], [[JavaScript JSON Syntax]]
|
||||
- **참조 맥락:** Referenced whenever reading or iterating the members of a parsed JSON object.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — JSON Objects — https://www.w3schools.com/js/js_json_objects.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-06-23: Initial draft synthesized from the W3Schools "JSON Objects" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
Reference in New Issue
Block a user