| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | [Back] [Original] |
Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 7.
* Some parts of this feature may have varying levels of support.
JSON.parse() JSON , JavaScript . , reviver , .
const json = '{"result":true, "count":42}';
const obj = JSON.parse(json);
console.log(obj.count);
// Expected output: 42
console.log(obj.result);
// Expected output: true
JSON.parse(text[, reviver])
textJSON . JSON JSON .
reviver Optional, .
JSON Object.
JSON SyntaxError.
JSON.parse() JSON.parse("{}"); // {}
JSON.parse("true"); // true
JSON.parse('"foo"'); // "foo"
JSON.parse('[1, 5, "false"]'); // [1, 5, "false"]
JSON.parse("null"); // null
reviver reviver . , ( ) reviver . reviver this , () . reviver undefined , . .
reviver , . .
JSON.parse(
'{"p": 5}',
(key, value) =>
typeof value === "number"
? value * 2 // 2
: value, //
);
// { p: 10 }
JSON.parse('{"1": 1, "2": 2, "3": {"4": 4, "5": {"6": 6}}}', (key, value) => {
console.log(key); // , ("")
return value; //
});
// 1
// 2
// 4
// 6
// 5
// 3
// ""
// SyntaxError
JSON.parse("[1, 2, 3, 4, ]");
JSON.parse('{"foo" : 1, }');
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-json.parse |
This page was last modified on 2025 2 11 by MDN contributors.
Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |