From dced1da5b58ef499b4048be212677f70eef01adb Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 15 Nov 2008 03:09:57 -0600 Subject: [PATCH] More JSON tweaks --- basis/json/json-docs.factor | 8 ++++++++ basis/json/json.factor | 4 ++++ basis/json/reader/reader-docs.factor | 2 +- basis/json/reader/reader.factor | 10 ++++++---- 4 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 basis/json/json-docs.factor diff --git a/basis/json/json-docs.factor b/basis/json/json-docs.factor new file mode 100644 index 0000000000..816e7236ac --- /dev/null +++ b/basis/json/json-docs.factor @@ -0,0 +1,8 @@ +IN: json +USING: help.markup help.syntax ; + +ARTICLE: "json" "JSON serialization" +{ $subsection "json.reader" } +{ $subsection "json.writer" } ; + +ABOUT: "json" diff --git a/basis/json/json.factor b/basis/json/json.factor index 08d2590ee7..d7cfc0e5bc 100644 --- a/basis/json/json.factor +++ b/basis/json/json.factor @@ -1,3 +1,7 @@ IN: json +USE: vocabs.loader SINGLETON: json-null + +"json.reader" require +"json.writer" require diff --git a/basis/json/reader/reader-docs.factor b/basis/json/reader/reader-docs.factor index 4700423db5..4446c385d3 100644 --- a/basis/json/reader/reader-docs.factor +++ b/basis/json/reader/reader-docs.factor @@ -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." } ; diff --git a/basis/json/reader/reader.factor b/basis/json/reader/reader.factor index f1520a9272..0014ba1eb1 100644 --- a/basis/json/reader/reader.factor +++ b/basis/json/reader/reader.factor @@ -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 \ No newline at end of file +;EBNF + +PRIVATE> + +: json> ( string -- object ) (json>) ; \ No newline at end of file