feat: add abnf and railroad diagram#25
Merged
DecimalTurn merged 3 commits intoJSONC-org:mainfrom Apr 22, 2026
Merged
Conversation
Member
Author
|
PR preview isn't working well, so I've merged and the railroad diagram is now visible here: |
Closed
Member
Author
|
Note that this was merged to facilitate the viewing experience for the railroad diagrams, but the abnf might still need some work before release. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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.jsoncwould output this: