examples/feature-tour.json puts every FSON extension in one place.
/* FSON feature tour.
Every syntax extension over plain JSON appears in this file;
see docs/notation.md for the grammar. /* Nested block comments
are allowed, like this one. */ Back at the outer level. */
{
// 1. Bare-name keys: letters and digits separated by single underscores.
bare_key_1: "no quotes needed",
// 2. Quoted keys for anything else.
"key with spaces": true,
// 3. Disabled members: '--' switches a member off without deleting it.
--switched_off: "still stored, invisible to queries",
--"also works on quoted keys": 42,
// 4. All JSON value types.
values: {
text: "string with escapes: \" \ \n \t €",
integer: -42,
fraction: 3.50,
exponent: 6.02e+23,
truthy: true,
falsy: false,
nothing: null,
list: [1, 2, 3],
nested: {}
},
// 5. Comments survive a read-modify-write cycle (try fson-check -i).
documented: "leading comment above" // trailing comment beside
/* dangling comments before the closing brace are preserved too */
}
The tour
| # | Feature | Page |
|---|---|---|
header /* … /* … */ … */ | a nested block comment — one comment, not a syntax error | Comments |
| 1 | bare_key_1: — a bare name | Keys & bare names |
| 2 | "key with spaces": — quote anything that is not a bare name | Keys & bare names |
| 3 | --switched_off: / --"also works…": — disabled members, invisible to queries, preserved verbatim | Disabled members |
| 4 | € in a string; 3.50 keeps its trailing zero; 6.02e+23; null; [] / {} | Strings, Numbers, Values |
| 5 | leading, trailing and dangling comment positions | Comments |
The round-trip claim, checked
fson-check -i feature-tour.json
git diff feature-tour.json # no change
3.50 stays 3.50 (not 3.5), € is decoded and re-escaped as €… actually written back as the raw UTF-8 €, every comment stays where it was, and --switched_off is still present with its prefix.
Reading a disabled member
auto r = Fson::load( "feature-tour.json" );
r.document->getString( "switched_off", "N/A" ); // "N/A" — disabled, invisible
Object& root = *r.document->getRootObject();
for( std::size_t k = 0; k < root.memberCount(); ++k )
if( root.getMember( k ).getKey().getName() == "switched_off" )
/* found it via the member API */;

