json_arr.gbnf 796 B

12345678910111213141516171819202122232425262728293031323334
  1. # This is the same as json.gbnf but we restrict whitespaces at the end of the root array
  2. # Useful for generating JSON arrays
  3. root ::= arr
  4. value ::= object | array | string | number | ("true" | "false" | "null") ws
  5. arr ::=
  6. "[\n" ws (
  7. value
  8. (",\n" ws value)*
  9. )? "]"
  10. object ::=
  11. "{" ws (
  12. string ":" ws value
  13. ("," ws string ":" ws value)*
  14. )? "}" ws
  15. array ::=
  16. "[" ws (
  17. value
  18. ("," ws value)*
  19. )? "]" ws
  20. string ::=
  21. "\"" (
  22. [^"\\\x7F\x00-\x1F] |
  23. "\\" (["\\bfnrt] | "u" [0-9a-fA-F]{4}) # escapes
  24. )* "\"" ws
  25. number ::= ("-"? ([0-9] | [1-9] [0-9]{0,15})) ("." [0-9]+)? ([eE] [-+]? [1-9] [0-9]{0,15})? ws
  26. # Optional space: by convention, applied in this grammar after literal chars when allowed
  27. ws ::= | " " | "\n" [ \t]{0,20}