@@ -659,14 +659,8 @@ literal = "`" json-value "`" ;; # Literal Expressions
659
659
; ; search({first: a, type: `"mytype"`}, {"a": "b", "c": "d"}) -> {"first": "b", "type": "mytype"}
660
660
; ; ```
661
661
662
- unescaped-literal = %x 20 -21 / ; space !
663
- %x 23 -5B / ; # - [
664
- %x 5D -5F / ; ] ^ _
665
- %x 61 -7A / ; a-z
666
- %x 7B -10FFFF ; {|}~ ...
667
- escaped-literal = escaped-char / (escape " `" )
668
662
number = [" -" ] 1 * digit
669
- digit = %x 30 -39
663
+ digit = %x 30 -39 ; 0-9
670
664
identifier = unquoted-string / quoted-string ; ; # Identifiers
671
665
; ; An identifier is the most basic expression and can be used to extract a single element from a JSON document.
672
666
; ; The return value for an identifier is the value associated with the identifier. If the identifier does not exist in the
@@ -694,10 +688,10 @@ unquoted-string = (%x41-5A / %x61-7A / %x5F) *( ; A-Za-z_
694
688
%x 41 -5A / ; A-Z
695
689
%x 5F / ; _
696
690
%x 61 -7A ) ; a-z
697
- quoted-string = quote 1 * (unescaped-char / escaped-char ) quote
691
+ quoted-string = quotation-mark 1 * (unescaped-char / escaped-char ) quotation-mark
698
692
unescaped-char = %x 20 -21 / %x 23 -5B / %x 5D -10FFFF
699
- escape = " \ "
700
- quote = %x 22 ; Double quote: '"'
693
+ escape = % x 5C ; \
694
+ quotation-mark = %x 22 ; "
701
695
escaped-char = escape (
702
696
%x 22 / ; " quotation mark U+0022
703
697
%x 5C / ; \ reverse solidus U+005C
@@ -709,38 +703,48 @@ escaped-char = escape (
709
703
%x 74 / ; t tab U+0009
710
704
%x 75 4HEXDIG ) ; uXXXX U+XXXX
711
705
712
- ; The `` json-value`` is any valid JSON value with the one exception that the
713
- ; ``%x60`` character must be escaped. While it's encouraged that implementations
714
- ; use any existing JSON parser for this grammar rule (after handling the escaped
715
- ; literal characters), the grammar rule is shown below for completeness::
716
-
706
+ ; ` json-value` is any valid JSON value with the one exception that each
707
+ ; U+0060 GRAVE ACCENT '`' must be escaped with a preceding backslash.
708
+ ; While implementations are encouraged to use any existing JSON parser for this
709
+ ; section of the grammar (after handling the escaped characters), a complete
710
+ ; set of rules derived from RFC 8259 is included below:
717
711
json-value = false / null / true / json-object / json-array /
718
- json-number / json-quoted-string
712
+ json-number / json-string
713
+ ws = * (
714
+ %x 20 / ; Space
715
+ %x 09 / ; Horizontal tab
716
+ %x 0A / ; Line feed or New line
717
+ %x 0D ) ; Carriage return
718
+ ; JSON literals
719
719
false = %x 66 . 61 . 6c . 73 . 65 ; false
720
720
null = %x 6e . 75 . 6c . 6c ; null
721
721
true = %x 74 . 72 . 75 . 65 ; true
722
- json-quoted-string = %x 22 * ( unescaped-literal / escaped-literal ) %x 22
722
+ ; JSON strings
723
+ json-string = quotation-mark * ( json-unescaped / json-escaped ) quotation-mark
724
+ json-unescaped = %x 20 -21 / ; space or '!' (precedes U+0022 '"')
725
+ %x 23 -5B / ; '#' through '[' (precedes U+005C '\')
726
+ %x 5D -5F / ; ']' through '_' (precedes U+0060 '`')
727
+ %x 61 -10FFFF ; 'a' and all following code points
728
+ json-escaped = escaped-char / (escape " `" )
729
+ ; JSON arrays
730
+ json-array = begin-array [ json-value * ( value-separator json-value ) ] end-array
723
731
begin-array = ws %x 5B ws ; [ left square bracket
724
- begin-object = ws %x 7B ws ; { left curly bracket
725
732
end-array = ws %x 5D ws ; ] right square bracket
726
- end-object = ws %x 7D ws ; } right curly bracket
727
- name-separator = ws %x 3A ws ; : colon
728
733
value-separator = ws %x 2C ws ; , comma
729
- ws = * (%x 20 / ; Space
730
- %x 09 / ; Horizontal tab
731
- %x 0A / ; Line feed or New line
732
- %x 0D ; Carriage return
733
- )
734
- json-object = begin-object [ member * ( value-separator member ) ] end-object
735
- member = json-quoted-string name-separator json-value
736
- json-array = begin-array [ json-value * ( value-separator json-value ) ] end-array
737
- json-number = [ minus ] int [ frac ] [ exp ]
738
- decimal-point = %x 2E ; .
739
- digit1-9 = %x 31 -39 ; 1-9
740
- e = %x 65 / %x 45 ; e E
741
- exp = e [ minus / plus ] 1 * digit
742
- frac = decimal-point 1 * digit
743
- int = zero / ( digit1-9 * digit )
744
- minus = %x 2D ; -
745
- plus = %x 2B ; +
746
- zero = %x 30 ; 0
734
+ ; JSON objects
735
+ json-object = begin-object [ member * ( value-separator member ) ] end-object
736
+ begin-object = ws %x 7B ws ; { left curly bracket
737
+ end-object = ws %x 7D ws ; } right curly bracket
738
+ member = json-string name-separator json-value
739
+ name-separator = ws %x 3A ws ; : colon
740
+ ; JSON numbers
741
+ json-number = [ minus ] int [ frac ] [ exp ]
742
+ decimal-point = %x 2E ; .
743
+ digit1-9 = %x 31 -39 ; 1-9
744
+ e = %x 65 / %x 45 ; e E
745
+ exp = e [ minus / plus ] 1 * digit
746
+ frac = decimal-point 1 * digit
747
+ int = zero / ( digit1-9 * digit )
748
+ minus = %x 2D ; -
749
+ plus = %x 2B ; +
750
+ zero = %x 30 ; 0
0 commit comments