--- 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).