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