Dialect::Fson (default)

Loses no information: comments, member order, key form, -- markers and number lexemes (hex, Infinity / -Infinity / NaN included) are all written back.

Format: 2-space indent; key: value, one member / element per line; compact {} / [] for empty containers unless they carry dangling comments; disabled members adjacent as --key: value; strings escape only ", \ and control characters (raw UTF-8, including U+2028 / U+2029, passes through); file ends with a newline.

Pretty output is a fixed point: write(parse(write(x))) == write(parse(x)).

Dialect::Json — strict JSON

  • comments omitted
  • every key quoted (preferBareKeys has no effect)
  • Number::Kind::Hex lexemes rewritten to plain decimal
  • writing Infinity / NegativeInfinity / NaN throws std::domain_error — strict JSON cannot represent it (fson-check --json catches it → exit 2)
  • |-block strings written as ordinary quoted strings
  • -- disabled members follow DisabledMemberPolicy; ConvertToComment behaves like Drop here (no comments in JSON)
  • containers left empty after filtering are written compact

Dialect::Json5 — JSON5-compliant

  • comments kept (header / leading / trailing / dangling / footer)
  • bare keys kept (same rule as Fson; preferBareKeys supported)
  • number lexemes verbatim — hex stays hex, Infinity / -Infinity / NaN stay literal
  • -- disabled members follow DisabledMemberPolicy; default ConvertToComment synthesizes a // key: value comment
  • any multi-line block comment (original or synthesized) is flattened to one // line per source line — JSON5 forbids nested block comments, the one place FSON and JSON5 diverge