| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/JSON | [Back] [Original] |
Get to know MDN better
JSON null JavaScript JavaScript JSON
JSON JavaScript JSON superset U+2028 LINE SEPARATOR U+2029 PARAGRAPH SEPARATOR JSON JavaScript SyntaxError
undefined JSON Babel JSON5 YAML
JavaScript JSON JSON
JSON ABNF IETF JSON (RFC)
JSON-text = ws value ws
begin-array = ws %x5B ws ; [ left square bracket
begin-object = ws %x7B ws ; { left curly bracket
end-array = ws %x5D ws ; ] right square bracket
end-object = ws %x7D ws ; } right curly bracket
name-separator = ws %x3A ws ; : colon
value-separator = ws %x2C ws ; , comma
ws = *(
%x20 / ; Space
%x09 / ; Horizontal tab
%x0A / ; Line feed or New line
%x0D ; Carriage return
)
value = false / null / true / object / array / number / string
false = %x66.61.6c.73.65 ; false
null = %x6e.75.6c.6c ; null
true = %x74.72.75.65 ; true
object = begin-object [ member *( value-separator member ) ]
end-object
member = string name-separator value
array = begin-array [ value *( value-separator value ) ] end-array
number = [ minus ] int [ frac ] [ exp ]
decimal-point = %x2E ; .
digit1-9 = %x31-39 ; 1-9
e = %x65 / %x45 ; e E
exp = e [ minus / plus ] 1*DIGIT
frac = decimal-point 1*DIGIT
int = zero / ( digit1-9 *DIGIT )
minus = %x2D ; -
plus = %x2B ; +
zero = %x30 ; 0
string = quotation-mark *char quotation-mark
char = unescaped /
escape (
%x22 / ; " quotation mark U+0022
%x5C / ; \ reverse solidus U+005C
%x2F / ; / solidus U+002F
%x62 / ; b backspace U+0008
%x66 / ; f form feed U+000C
%x6E / ; n line feed U+000A
%x72 / ; r carriage return U+000D
%x74 / ; t tab U+0009
%x75 4HEXDIG ) ; uXXXX U+XXXX
escape = %x5C ; \
quotation-mark = %x22 ; "
unescaped = %x20-21 / %x23-5B / %x5D-10FFFF
HEXDIG = DIGIT / %x41-46 / %x61-66 ; 0-9, A-F, or a-f
; HEXDIG equivalent to HEXDIG rule in [RFC5234]
DIGIT = %x30-39 ; 0-9
; DIGIT equivalent to DIGIT rule in [RFC5234]
JSONNumber JSONString (U+0009) (U+000D) (U+000A) (U+0020)
JSON.isRawJSON()JSON.parse() text JSON
JSON.rawJSON()JSON JSON JSON JSON JSON JSON
JSON.stringify()JSON
{
"browsers": {
"firefox": {
"name": "Firefox",
"pref_url": "about:config",
"releases": {
"1": {
"release_date": "2004-11-09",
"status": "retired",
"engine": "Gecko",
"engine_version": "1.7"
}
}
}
}
}
JSON.parse() JSON JavaScript
const jsonText = `{
"browsers": {
"firefox": {
"name": "Firefox",
"pref_url": "about:config",
"releases": {
"1": {
"release_date": "2004-11-09",
"status": "retired",
"engine": "Gecko",
"engine_version": "1.7"
}
}
}
}
}`;
console.log(JSON.parse(jsonText));
JSON JavaScript JavaScript JSON 12345678901234567890 === 12345678901234567000 JavaScript 12345678901234567890 JSON JavaScript
const data = {
// BigInt
//
//
gross_gdp: 12345678901234567890n,
};
JSON.stringify replacer toJSON JSON.stringify JSON.parse("12345678901234567890") 12345678901234568000 JSON 2 1 JSON 1 JSON JSON JSON HTTP
JavaScript JSON JavaScript
BigInt JSON toJSON JSON.stringify()
// toJSON()
BigInt.prototype.toJSON = function () {
return this.toString();
};
const str1 = JSON.stringify(data);
// JSON.stringify()
const str2 = JSON.stringify(data, (key, value) => {
if (key === "gross_gdp") {
return value.toString();
}
return value;
});
JSON {"gross_gdp":"12345678901234567890"} JSON
Python JSON JSON JavaScript JSON.rawJSON() JSON JSON
// toJSON()
BigInt.prototype.toJSON = function () {
return JSON.rawJSON(this.toString());
};
const str1 = JSON.stringify(data);
// JSON.stringify()
const str2 = JSON.stringify(data, (key, value) => {
if (key === "gross_gdp") {
return JSON.rawJSON(value.toString());
}
return value;
});
JSON.rawJSON JSON JSON {"gross_gdp":12345678901234567890} JSON JavaScript
JavaScript JSON JSON.parse() JSON.parse() context.source
const parsedData = JSON.parse(str, (key, value, context) => {
if (key === "gross_gdp") {
//
return BigInt(context.source);
}
return value;
});
// { gross_gdp: 12345678901234567890n }
| ECMAScript 2027 LanguageSpecification # sec-json-object |
| Web Proxy Viewer | New URL | Original Page |