More JSON tweaks
parent
e313988bf0
commit
dced1da5b5
|
@ -0,0 +1,8 @@
|
|||
IN: json
|
||||
USING: help.markup help.syntax ;
|
||||
|
||||
ARTICLE: "json" "JSON serialization"
|
||||
{ $subsection "json.reader" }
|
||||
{ $subsection "json.writer" } ;
|
||||
|
||||
ABOUT: "json"
|
|
@ -1,3 +1,7 @@
|
|||
IN: json
|
||||
USE: vocabs.loader
|
||||
|
||||
SINGLETON: json-null
|
||||
|
||||
"json.reader" require
|
||||
"json.writer" require
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
USING: help.markup help.syntax ;
|
||||
IN: json.reader
|
||||
|
||||
HELP: json> ( string -- object )
|
||||
HELP: json>
|
||||
{ $values { "string" "a string in JSON format" } { "object" "a deserialized object" } }
|
||||
{ $description "Deserializes the JSON formatted string into a Factor object. JSON objects are converted to Factor hashtables. All other JSON objects convert to their obvious Factor equivalents." } ;
|
||||
|
||||
|
|
|
@ -9,10 +9,8 @@ IN: json.reader
|
|||
|
||||
: grammar-list>vector ( seq -- vec ) first2 values swap prefix ;
|
||||
|
||||
PRIVATE>
|
||||
|
||||
! Grammar for JSON from RFC 4627
|
||||
EBNF: json>
|
||||
EBNF: (json>)
|
||||
|
||||
ws = (" " | "\r" | "\t" | "\n")*
|
||||
|
||||
|
@ -56,4 +54,8 @@ val = true
|
|||
|
||||
value = ws val:v ws => [[ v ]]
|
||||
|
||||
;EBNF
|
||||
;EBNF
|
||||
|
||||
PRIVATE>
|
||||
|
||||
: json> ( string -- object ) (json>) ;
|
Loading…
Reference in New Issue