appendicies: update canonical JSON grammar (#2368)
Some checks are pending
Spec / 🔎 Validate OpenAPI specifications (push) Waiting to run
Spec / 🔎 Check Event schema examples (push) Waiting to run
Spec / 🔎 Check OpenAPI definitions examples (push) Waiting to run
Spec / 🔎 Check JSON Schemas inline examples (push) Waiting to run
Spec / ⚙️ Calculate baseURL for later jobs (push) Waiting to run
Spec / 🐍 Build OpenAPI definitions (push) Blocked by required conditions
Spec / 📢 Run towncrier for changelog (push) Waiting to run
Spec / 📖 Build the spec (push) Blocked by required conditions
Spec / 🔎 Validate generated HTML (push) Blocked by required conditions
Spec / 📖 Build the historical backup spec (push) Blocked by required conditions
Spec / Create release (push) Blocked by required conditions
Spell Check / Spell Check with Typos (push) Waiting to run

Signed-off-by: famfo <famfo@famfo.xyz>
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
This commit is contained in:
famfo 2026-05-05 16:51:52 +02:00 committed by GitHub
parent ec24e73db1
commit 7de46ddf97
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 32 additions and 25 deletions

View file

@ -0,0 +1,2 @@
Update the canonical JSON grammar with case sensitive strings and ABNF builtins
to be easier to understand.

View file

@ -131,32 +131,37 @@ def canonical_json(value):
#### Grammar #### Grammar
Adapted from the grammar in <http://tools.ietf.org/html/rfc7159> Adapted grammar from <http://tools.ietf.org/html/rfc7159> removing
removing insignificant whitespace, fractions, exponents and redundant insignificant whitespace, fractions, exponents and redundant character escapes
character escapes. written in [ABNF](https://datatracker.ietf.org/doc/html/rfc5234) with
[case sensitive strings](https://datatracker.ietf.org/doc/html/rfc7405).
value = false / null / true / object / array / number / string ```
false = %x66.61.6C.73.65 value = false / null / true / object / array / number / string
null = %x6E.75.6C.6C false = %s"false"
true = %x74.72.75.65 null = %s"null"
object = %x7B [ member *( %x2C member ) ] %x7D true = %s"true"
member = string %x3A value object = "{" [ member *( "," member ) ] "}"
array = %x5B [ value *( %x2C value ) ] %x5D member = string ":" value
number = [ %x2D ] int array = "[" [ value *( "," value ) ] "]"
int = %x30 / ( %x31-39 *digit ) number = [ "-" ] int
digit = %x30-39 int = %x30 / ( %x31-39 *DIGIT ) ; Integer without leading zeros
string = %x22 *char %x22 string = DQUOTE *char DQUOTE ; Quoted characters
char = unescaped / %x5C escaped char = unescaped / "\" escaped
unescaped = %x20-21 / %x23-5B / %x5D-10FFFF unescaped = %x20-21 / %x23-5B / %x5D-10FFFF ; All UTF-8 codepoints except ASCII control
escaped = %x22 ; " quotation mark U+0022 ; characters, " and \
/ %x5C ; \ reverse solidus U+005C escaped = %x62 ; b backspace U+0008
/ %x62 ; b backspace U+0008
/ %x66 ; f form feed U+000C
/ %x6E ; n line feed U+000A
/ %x72 ; r carriage return U+000D
/ %x74 ; t tab U+0009 / %x74 ; t tab U+0009
/ %x75.30.30.30 (%x30-37 / %x62 / %x65-66) ; u000X / %x6E ; n line feed U+000A
/ %x75.30.30.31 (%x30-39 / %x61-66) ; u001X / %x66 ; f form feed U+000C
/ %x72 ; r carriage return U+000D
/ %x22 ; " quotation mark U+0022
/ %x5C ; \ reverse solidus U+005C
/ %s"u000" (%x30-37 / %x62 / %x65-66) ; All ASCII control characters which do not have
; dedicated escape sequences (for example \n).
; u000X, where X is [0-7, b, e, f]
/ %s"u001" (%x30-39 / %x61-66) ; u001X, where X is [0-9, a-f]
```
#### Examples #### Examples