aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/data/format/json.lux
diff options
context:
space:
mode:
authorEduardo Julian2021-08-20 03:12:49 -0400
committerEduardo Julian2021-08-20 03:12:49 -0400
commit374ccf07246484eb7beb2cd87f3fc88396373ee1 (patch)
tree4ed37fd579df1765dde6b57450f239844f7a07c1 /stdlib/source/library/lux/data/format/json.lux
parentd772fe99d5d4990c6774481fb64d12280cdb6aae (diff)
More fixes.
Diffstat (limited to 'stdlib/source/library/lux/data/format/json.lux')
-rw-r--r--stdlib/source/library/lux/data/format/json.lux26
1 files changed, 6 insertions, 20 deletions
diff --git a/stdlib/source/library/lux/data/format/json.lux b/stdlib/source/library/lux/data/format/json.lux
index c6a7ebef0..ed2643efa 100644
--- a/stdlib/source/library/lux/data/format/json.lux
+++ b/stdlib/source/library/lux/data/format/json.lux
@@ -1,6 +1,4 @@
(.module:
- {#.doc (.example "Functionality for reading and writing values in the JSON format."
- "For more information, please see: http://www.json.org/")}
[library
[lux #*
["." meta (#+ monad)]
@@ -68,14 +66,6 @@
(|>> (dictionary.of_list text.hash) #..Object))
(syntax: .public (json [token <code>.any])
- {#.doc (example "A simple way to produce JSON literals."
- (json #null)
- (json #1)
- (json +123.456)
- (json "this is a string")
- (json ["this" "is" "an" "array"])
- (json {"this" "is"
- "an" "object"}))}
(let [(^open ".") ..monad
wrapper (function (_ x) (` (..json (~ x))))]
(case token
@@ -111,7 +101,6 @@
(in (list token)))))
(def: .public (fields json)
- {#.doc "Get all the fields in a JSON object."}
(-> JSON (Try (List String)))
(case json
(#Object obj)
@@ -121,7 +110,6 @@
(#try.Failure ($_ text\compose "Cannot get the fields of a non-object."))))
(def: .public (field key json)
- {#.doc "A JSON object field getter."}
(-> String JSON (Try JSON))
(case json
(#Object obj)
@@ -136,7 +124,6 @@
(#try.Failure ($_ text\compose "Cannot get field '" key "' on a non-object."))))
(def: .public (has key value json)
- {#.doc "A JSON object field setter."}
(-> String JSON JSON (Try JSON))
(case json
(#Object obj)
@@ -145,9 +132,8 @@
_
(#try.Failure ($_ text\compose "Cannot set field '" key "' on a non-object."))))
-(template [<name> <tag> <type> <desc>]
+(template [<name> <tag> <type>]
[(def: .public (<name> key json)
- {#.doc (code.text ($_ text\compose "A JSON object field getter for " <desc> "."))}
(-> Text JSON (Try <type>))
(case (field key json)
(#try.Success (<tag> value))
@@ -159,11 +145,11 @@
(#try.Failure error)
(#try.Failure error)))]
- [boolean_field #Boolean Boolean "booleans"]
- [number_field #Number Number "numbers"]
- [string_field #String String "strings"]
- [array_field #Array Array "arrays"]
- [object_field #Object Object "objects"]
+ [boolean_field #Boolean Boolean]
+ [number_field #Number Number]
+ [string_field #String String]
+ [array_field #Array Array]
+ [object_field #Object Object]
)
(implementation: .public equivalence