Get to know MDN better
此頁面由社群從英文翻譯而來。了解更多並加入 MDN Web Docs 社群。
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
* Some parts of this feature may have varying levels of support.
JSON 物件包含了解析、或是轉換為 JavaScript Object Notation(JSON)格式的方法。這物件不能被呼叫或建構;而除了它的兩個方法屬性以外,本身也沒有特別的功能。
JSON 是序列物件、陣列、數字、字串、布林值、還有 null 的語法。它建基、但不同於 JavaScript:有些 JavaScript 不是 JSON、而有些 JSON 不是 JavaScript。請參見 JSON: The JavaScript subset that isn't。
| 物件與陣列 | 屬性名稱必須是包含在雙引號中的字串;禁止尾後逗號。 |
| 數字 | 數字不可以 0 作為開頭;小數點前面必須至少有一位數字;不支援 NaN 和 Infinity。 |
Insignificant whitespace may be present anywhere except within a JSONNumber (numbers must contain no whitespace) or JSONString (where it is interpreted as the corresponding character in the string, or would cause an error). The tab character (U+0009), carriage return (U+000D), line feed (U+000A), and space (U+0020) characters are the only valid whitespace characters.
解析 JSON 字串,能改變給定值和屬性、接著回傳解析值。
JSON.stringify()回傳給定的 JSON 對應字串,可自行決定只想包括哪些特定屬性、或替換的屬性值。
| ECMAScript® 2027 Language Specification # sec-json-object |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025年7月14日 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.