aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/data/format/json.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/data/format/json.lux22
1 files changed, 11 insertions, 11 deletions
diff --git a/stdlib/source/lux/data/format/json.lux b/stdlib/source/lux/data/format/json.lux
index 573849b9e..0ce1b602a 100644
--- a/stdlib/source/lux/data/format/json.lux
+++ b/stdlib/source/lux/data/format/json.lux
@@ -109,11 +109,11 @@
## [Values]
(def: #hidden (show-null _) (-> Null Text) "null")
(do-template [<name> <type> <codec>]
- [(def: <name> (-> <type> Text) (:: <codec> encode))]
+ [(def: <name> (-> <type> Text) <codec>)]
- [show-boolean Boolean bool;Codec<Text,Bool>]
- [show-number Number number;Codec<Text,Real>]
- [show-string String text;Codec<Text,Text>])
+ [show-boolean Boolean (:: bool;Codec<Text,Bool> encode)]
+ [show-number Number (:: number;Codec<Text,Real> encode)]
+ [show-string String text;encode])
(def: (show-array show-json elems)
(-> (-> JSON Text) (-> Array Text))
@@ -126,7 +126,7 @@
(format "{"
(|> object
d;entries
- (L/map (function [[key value]] (format (:: text;Codec<Text,Text> encode key) ":" (show-json value))))
+ (L/map (function [[key value]] (format (show-string key) ":" (show-json value))))
(text;join-with ","))
"}"))
@@ -395,7 +395,7 @@
[text Text #String "text" id]
)
-(do-template [<test> <check> <type> <eq> <codec> <tag> <desc> <pre>]
+(do-template [<test> <check> <type> <eq> <encoder> <tag> <desc> <pre>]
[(def: #export (<test> test json)
{#;doc (#;TextA (format "Asks whether a JSON value is a " <desc> "."))}
(-> <type> (Parser Bool))
@@ -415,15 +415,15 @@
(if (:: <eq> = test value)
(#R;Success [])
(#R;Error (format "Value mismatch: "
- (:: <codec> encode test) "=/=" (:: <codec> encode value)))))
+ (<encoder> test) "=/=" (<encoder> value)))))
_
(#R;Error (format "JSON value is not a " <desc> ": " (show-json json)))))]
- [bool? bool! Bool bool;Eq<Bool> bool;Codec<Text,Bool> #Boolean "boolean" id]
- [int? int! Int number;Eq<Int> number;Codec<Text,Int> #Number "number" real-to-int]
- [real? real! Real number;Eq<Real> number;Codec<Text,Real> #Number "number" id]
- [text? text! Text text;Eq<Text> text;Codec<Text,Text> #String "string" id]
+ [bool? bool! Bool bool;Eq<Bool> (:: bool;Codec<Text,Bool> encode) #Boolean "boolean" id]
+ [int? int! Int number;Eq<Int> (:: number;Codec<Text,Int> encode) #Number "number" real-to-int]
+ [real? real! Real number;Eq<Real> (:: number;Codec<Text,Real> encode) #Number "number" id]
+ [text? text! Text text;Eq<Text> text;encode #String "string" id]
)
(def: #export (char json)