Two comment forms exist anywhere whitespace may appear.

Line comments

// … runs to the end of the line.

Block comments — and they nest

/* … */ may span lines and may nest:

/* outer /* inner */ still outer */

is one comment. This is the one place FSON deliberately departs from JSON5 (which forbids nesting): commenting out a region that already contains a block comment has to be safe.

Where comments may appear

Wherever whitespace is allowed — described by skip_comments_and_blanks, which is "zero or more of (whitespace | line comment | block comment)":

Comments are data

The fson library treats comments as first-class citizens of the model. It records where each one is attached —

  • before a member or element (leading),
  • at the end of its line (trailing),
  • before a closing } / ] (dangling),
  • around the whole document (header / footer) —

and writes every one of them back. A read–modify–write cycle never loses a comment, and comment text is never re-indented or reflowed: only the surrounding whitespace is normalised. See Comment & CommentList.