FsonWriter has three dialects. The default, Fson, is the comment-preserving pretty-printer from Modifying & Saving. The other two convert.
Json — strict JSON
FsonWriter w;
w.setDialect( FsonWriter::Dialect::Json );
w.write( doc, std::cout );
or fson-check --json config.fson.
| Rule | Effect | |
|---|---|---|
| comments | removed — plain JSON cannot carry them | |
| keys | all quoted | |
| hex lexemes | rewritten to decimal (0x40 → 64) | |
Infinity / -Infinity / NaN | throws std::domain_error — no JSON representation. fson-check catches it and reports a write failure (exit 2) | |
| `\ | `-block strings | written as an ordinary quoted string |
-- disabled members | dropped (JSON cannot hold a comment; --keep still works) | |
--bare | rejected — JSON keys are always quoted |
Json5 — JSON5-compliant
w.setDialect( FsonWriter::Dialect::Json5 );
or fson-check --json5 config.fson.
| Rule | Effect |
|---|---|
| comments | kept — a nested block comment is flattened to one // line per source line (JSON5 forbids nesting) |
| bare keys | stay bare |
| number lexemes | verbatim — hex stays hex, Infinity / NaN stay literal |
-- disabled members | default: turned into a comment rendering key: value |
--bare | supported (JSON5 allows bare keys) |
DisabledMemberPolicy
-- has no equivalent in either target, so a disabled member is handled by FsonWriter::DisabledMemberPolicy:
| Policy | fson-check flag | Behaviour |
|---|---|---|
ConvertToComment | (default) | JSON5: synthesize a // key: value comment (split over lines for a container). JSON: same as Drop. |
Keep | --keep | emit as an ordinary member, no -- — may produce a duplicate key |
Drop | --drop-disabled | emit nothing |
Combination rules
--json and --json5 are mutually exclusive, and neither can be combined with -i (an in-place conversion would silently lose structure — write to --output or stdout). --keep and --drop-disabled are mutually exclusive and each requires --json or --json5.
fson-check --json --keep config.fson | jq '.database'
fson-check --json5 --bare config.fson --output config.json5
Full flag reference: Tools › fson-check.

