Skip to content

Instantly share code, notes, and snippets.

@dockimbel
Forked from Skrylar/JSON.red
Last active September 29, 2020 04:13
Show Gist options
  • Save dockimbel/47e9578d910d2be60dea to your computer and use it in GitHub Desktop.
Save dockimbel/47e9578d910d2be60dea to your computer and use it in GitHub Desktop.
JSON minminal parser for Red
Red []
digit-nz: charset "123456789"
digit: append copy digit-nz #"0"
hex: append copy digit "abcdefABCDEF"
sign: charset "+-"
exponent-e: charset "eE"
dquot: #"^""
exponent: [ exponent-e opt sign some digit ]
decimal: [ #"." some digit ]
number: [ opt #"-" [ "0" | digit-nz any digit ] opt decimal opt exponent ]
array: [ "[" opt [ value any ["," value] ] "]" ]
value: [ string | number | array | "true" | "false" | "null" ]
str-escape: [ dquot | #"\" | #"/" | "b" | "f" | "n" | "r" | "t" | "u" 4 hex ]
string: [ dquot any [#"\" str-escape | not dquot skip ] dquot ]
print parse "[^"Fish bone^"]" value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment