FSON, JSON5'in pragmatik bir supersetidir; tek istisnası nested block

yorumlardır — JSON5 onları yasaklar, FSON destekler. Yorumsuz veya

yalnız tek-derinlikli /* */ kullanan her JSON5 dosyası geçerli

FSON'dur.

In English: FSON is a pragmatic superset of JSON5. Every JSON5 file that is comment-free, or uses only single-depth /* */ comments, is a valid FSON file.

Everywhere else, FSON's grammar is JSON5's grammar plus FSON's own additions — -- disabled members, nested block comments, %include directives, |-block strings, and the dotted-string path API.

What FSON adopted from JSON5 (v0.9.0.0)

  • single-quoted and double-quoted strings
  • trailing commas in objects and arrays
  • extended number literals: hex (0xFF), Infinity / -Infinity / NaN, a leading +, a leading dot (.5), a trailing dot (5.)
  • extended whitespace (NBSP, BOM, U+2028/2029, category Zs)
  • any value as the document root
  • \xXX, \v, \0 and line-continuation escapes; any other char after \ is itself

The two deliberate exceptions

  1. Nested block comments. JSON5 forbids /* a /* b */ c */; FSON makes it one comment. A JSON5 file that happens to contain a nested block comment is not valid JSON5 in the first place, so this only matters the other way around: an FSON file using nested comments is not valid JSON5.
  2. Bare-key grammar. FSON's name production does not go as far as JSON5's full IdentifierName. A JSON5 file with a bare key like $foo, _x, or a Unicode-identifier key needs that key quoted to also be valid FSON.

Converting

fson-check --json5 file.fson emits JSON5-compliant output: comments kept (nested ones flattened to one // line per source line, since JSON5 forbids nesting), bare keys kept bare, number lexemes verbatim. See Converting to JSON / JSON5.