Skip to content

feat: add abnf and railroad diagram#25

Merged
DecimalTurn merged 3 commits intoJSONC-org:mainfrom
DecimalTurn:abnf
Apr 22, 2026
Merged

feat: add abnf and railroad diagram#25
DecimalTurn merged 3 commits intoJSONC-org:mainfrom
DecimalTurn:abnf

Conversation

@DecimalTurn
Copy link
Copy Markdown
Member

@DecimalTurn DecimalTurn commented Apr 22, 2026

First version of the ABNF for JSONC.

Note that the current vesion:

  • Doesn't support trailing commas. That's because this will be the ABNF for v0. Trailing commas will be part of v1.

  • Includes the notion of Line Seperator (LS) and Paragraph Seperator (PS) since that is part of the EcmaScript standard. The current approach is to accept them as comment terminator. Note that if they are not considered as comment terminator and can live inside single-line comemnts, someone could craft a malicious JSONC comment that would include those characters and could hide JS code that would be executed if used inside a JavaScript file.

    If LS is not a comment terminator, but is allowed to appear on a single-line comment line as part of the comment, you could have the following:

    // test.jsonc
    {
      // U+2028 ->
 console.log('rce');
    }

    Which would be valid JSONC with a simple harmless comment inside an empty object. However, if transferred to a JS file or run form Node,js, it would cause the command to execute (ie. node test.jsonc would output this:

    rce
    

@DecimalTurn DecimalTurn marked this pull request as ready for review April 22, 2026 21:49
@DecimalTurn DecimalTurn merged commit a7424f2 into JSONC-org:main Apr 22, 2026
1 check passed
@DecimalTurn DecimalTurn deleted the abnf branch April 22, 2026 21:49
@DecimalTurn
Copy link
Copy Markdown
Member Author

PR preview isn't working well, so I've merged and the railroad diagram is now visible here:
https://jsonc.org/grammar/railroad-diagram.html

@DecimalTurn DecimalTurn mentioned this pull request Apr 22, 2026
@DecimalTurn
Copy link
Copy Markdown
Member Author

DecimalTurn commented Apr 23, 2026

Note that this was merged to facilitate the viewing experience for the railroad diagrams, but the abnf might still need some work before release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant