In what follows we'll present a tweaked variant of BNF geared towards describing JSON-based languages.

These are the extensions or changes to the "standard" BNF syntax:

  • there are two syntax variants:
  • "textual", for denoting arbitrary character sequences (the original intended usage);
  • "JSON", for denoting arbitrary JSON structures (the extension or repurposing);
  • in all variants the encoding of the resulting character sequence is UTF-8, and a character can be any valid Unicode character, including control sequences, except the \0 character ("null"); (however ASCII is preferred whenever possible;)
  • in the textual variant all characters must be explicitly described (i.e. whitespace must be denoted as ` `, etc.);
  • in the JSON variant, whitespace is implicit and non-important;
  • the non-terminals must be enclosed in backquotes (`), instead of single or double quotes (', "); (allowed only in textual variant;) (in order to allow JSON string literals to be expressed;)
  • the non-terminals enclosed in single or double quotes (', ") must be taken as such (thus including the quotes); (allowed only in JSON variant;)
  • the usage of square or curly brackets ([, ], {, }) is disallowed outside the JSON-systax (see below);
  • the usage of square or curly brackets ([, ], {, }) ...