コンテンツへスキップ
uencoder

JSON RFC 8259 仕様

The JSON データ interchange 整形 grammar, 値 型, および interchange ルール per RFC 8259.

Value Types

JSON defines six structural value types organized into a tree rooted at a single value. The scalar types are string, number, boolean, and null, while the composite types are object and array. Strings are double-quoted Unicode with escape sequences, numbers are decimal with optional exponent, and booleans are the literals true and false. The format is intentionally minimal to maximize interoperability across languages.

object
Unordered collection of name-value pairs
{"a": 1}
array
Ordered sequence of values
[1, 2, 3]
string
Double-quoted Unicode with escapes
"hello"
number
Decimal with optional fraction and exponent
1.5e3
true/false/null
Boolean and null literals
true, null

Interchange Encoding

RFC 8259 requires that JSON exchanged between systems be encoded in UTF-8, removing the earlier ambiguity that allowed UTF-16 and UTF-32. A JSON text must be a single scalar, object, or array value, though some parsers accept bare scalars leniently. Duplicate member names within an object are not forbidden but produce implementation-defined behavior, so generators should avoid them. Numbers with leading zeros or plus signs are invalid.

Number Precision Pitfalls

JSON numbers have no explicit integer or float distinction, leading to precision loss when parsed into language-native doubles. Integers exceeding 2 to the 53 cannot be represented exactly in a JavaScript number. Protocols requiring integer precision should encode large integers as strings or use a JSON Schema format annotation. Always validate number ranges in application logic rather than relying on parser behavior.

関連ツール

参考链接