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>
6.3 KiB
id, title, category, status, verification_status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, created_at, updated_at, review_reason, merge_history, tags, raw_sources, applied_in, github_commit
| id | title | category | status | verification_status | canonical_id | aliases | duplicate_of | source_trust_level | confidence_score | created_at | updated_at | review_reason | merge_history | tags | raw_sources | applied_in | github_commit | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| json-stringify | JSON Stringify | Frontend | draft | conceptual |
|
B | 0.9 | 2026-06-23 | 2026-06-23 |
|
|
JSON Stringify
🎯 한 줄 통찰 (One-line insight)
When sending data to a web server the data has to be a string; JSON.stringify() converts any JavaScript datatype into a JSON-notation string — converting dates to strings and removing functions, since JSON allows neither. [S1]
🧠 핵심 개념 (Core concepts)
- Sending data needs a string — when sending data to a web server, the data has to be a string; convert any JavaScript datatype with
JSON.stringify(). [S1] - Works on objects and arrays — the result is a string following JSON notation, ready to be sent to a server. [S1]
- Text storage — text is always a legal storage format; combined with
localStorage, JSON lets you store and reload JavaScript objects. [S1] - Dates become strings — in JSON, date objects are not allowed;
JSON.stringify()converts any Date objects into strings (convert back at the receiver). [S1] - Functions are removed — in JSON, functions are not allowed as object values;
JSON.stringify()removes any functions (both the key and the value). [S1]
🧩 추출된 패턴 (Extracted patterns)
- Serialize-then-send —
JSON.stringify(obj)produces a transmittable string. [S1] - Round-trip storage —
JSON.stringifyto save inlocalStorage,JSON.parseto read it back. [S1] - Pre-stringify a function to keep it — call
obj.fn = obj.fn.toString()before stringifying so the function survives as a string. [S1]
📖 세부 내용 (Details)
A common use of JSON is to exchange data to/from a web server. When sending data to a web server, the data has to be a string. You can convert any JavaScript datatype into a string with JSON.stringify(). [S1]
Stringify a JavaScript object
const obj = {name: "John", age: 30, city: "New York"};
const myJSON = JSON.stringify(obj);
The result will be a string following the JSON notation. myJSON is now a string, and ready to be sent to a server. [S1]
Stringify a JavaScript array
const arr = ["John", "Peter", "Sally", "Jane"];
const myJSON = JSON.stringify(arr);
The result will be a string following the JSON notation. myJSON is now a string, and ready to be sent to a server. [S1]
Storing data When storing data, the data has to be a certain format, and regardless of where you choose to store it, text is always one of the legal formats. JSON makes it possible to store JavaScript objects as text. Example storing and retrieving data in local storage: [S1]
const myObj = {name: "John", age: 31, city: "New York"};
const myJSON = JSON.stringify(myObj);
localStorage.setItem("testJSON", myJSON);
let text = localStorage.getItem("testJSON");
let obj = JSON.parse(text);
document.getElementById("demo").innerHTML = obj.name;
Stringify a number [S1]
const num = 123e-5;
const myJSON = JSON.stringify(num);
Stringify a boolean [S1]
let bool = new Boolean(1);
const myJSON = JSON.stringify(bool);
Stringify a date
In JSON, date objects are not allowed. The JSON.stringify() function will convert any Date objects into strings. [S1]
const obj = {name: "John", today: new Date(), city : "New York"};
const myJSON = JSON.stringify(obj);
You can convert the string back into a date object at the receiver. [S1]
Stringify a function
In JSON, functions are not allowed as object values. The JSON.stringify() function will remove any functions from a JavaScript object, both the key and the value. [S1]
const obj = {name: "John", age: function () {return 30;}, city: "New York"};
const myJSON = JSON.stringify(obj);
You can preserve a function by converting it to a string before stringifying: [S1]
const obj = {name: "John", age: function () {return 30;}, city: "New York"};
obj.age = obj.age.toString();
const myJSON = JSON.stringify(obj);
If you send functions using JSON, the functions will lose their scope, and the receiver would have to use eval() to convert them back into functions. [S1]
🛠️ 적용 사례 (Applied in summary)
Applied examples on the page: serialize an object and an array for sending to a server; round-trip an object through localStorage; stringify numbers, booleans, dates, and functions, including the .toString() trick to keep a function. No external project/commit applications found in the source.
💻 코드 패턴 (Code patterns)
Serialize an object to send to a server:
const obj = {name: "John", age: 30, city: "New York"};
const myJSON = JSON.stringify(obj);
Round-trip an object through local storage:
const myJSON = JSON.stringify(myObj);
localStorage.setItem("testJSON", myJSON);
let obj = JSON.parse(localStorage.getItem("testJSON"));
⚖️ 모순 및 업데이트 (Contradictions & updates)
No contradictions found in the source.
✅ 검증 상태 및 신뢰도
- 상태: draft
- 검증 단계: conceptual (실제 적용 사례 발견 시 applied/validated로 승격 가능)
- 출처 신뢰도: B (W3Schools — widely used educational reference, not a primary standards body)
- 신뢰 점수: 0.90
- 중복 검사 결과: 신규 생성 (New discovery)
🔗 지식 그래프 (Knowledge Graph)
- 상위/루트: JavaScript Tutorial
- 관련 개념: JavaScript JSON Parse, JavaScript JSON, JavaScript JSON Data Types, JavaScript JSON Objects
- 참조 맥락: Referenced whenever serializing JavaScript data for transmission to a server or storage.
📚 출처 (Sources)
- [S1] W3Schools — JSON Stringify — https://www.w3schools.com/js/js_json_stringify.asp
📝 변경 이력 (Change history)
- 2026-06-23: Initial draft synthesized from the W3Schools "JSON Stringify" page (Astra wiki-curation, P-Reinforce v3.1 format).