More JSON tweaks

db4
Slava Pestov 2008-11-15 03:09:57 -06:00
parent e313988bf0
commit dced1da5b5
4 changed files with 19 additions and 5 deletions

View File

@ -0,0 +1,8 @@
IN: json
USING: help.markup help.syntax ;
ARTICLE: "json" "JSON serialization"
{ $subsection "json.reader" }
{ $subsection "json.writer" } ;
ABOUT: "json"

View File

@ -1,3 +1,7 @@
IN: json IN: json
USE: vocabs.loader
SINGLETON: json-null SINGLETON: json-null
"json.reader" require
"json.writer" require

View File

@ -3,7 +3,7 @@
USING: help.markup help.syntax ; USING: help.markup help.syntax ;
IN: json.reader IN: json.reader
HELP: json> ( string -- object ) HELP: json>
{ $values { "string" "a string in JSON format" } { "object" "a deserialized object" } } { $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." } ; { $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." } ;

View File

@ -9,10 +9,8 @@ IN: json.reader
: grammar-list>vector ( seq -- vec ) first2 values swap prefix ; : grammar-list>vector ( seq -- vec ) first2 values swap prefix ;
PRIVATE>
! Grammar for JSON from RFC 4627 ! Grammar for JSON from RFC 4627
EBNF: json> EBNF: (json>)
ws = (" " | "\r" | "\t" | "\n")* ws = (" " | "\r" | "\t" | "\n")*
@ -57,3 +55,7 @@ val = true
value = ws val:v ws => [[ v ]] value = ws val:v ws => [[ v ]]
;EBNF ;EBNF
PRIVATE>
: json> ( string -- object ) (json>) ;