json.gbnf 665 B

1234567891011121314151617181920212223242526272829
  1. # Grammar for subset of JSON - doesn't support full string or number syntax
  2. root ::= object
  3. value ::= object | array | string | number | boolean | "null"
  4. object ::=
  5. "{" ws (
  6. string ":" ws value
  7. ("," ws string ":" ws value)*
  8. )? "}"
  9. array ::=
  10. "[" ws (
  11. value
  12. ("," ws value)*
  13. )? "]"
  14. string ::=
  15. "\"" (
  16. [^"\\] |
  17. "\\" (["\\/bfnrt] | "u" [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F]) # escapes
  18. )* "\"" ws
  19. # Only plain integers currently
  20. number ::= "-"? [0-9]+ ws
  21. boolean ::= ("true" | "false") ws
  22. # Optional space: by convention, applied in this grammar after literal chars when allowed
  23. ws ::= ([ \t\n] ws)?