aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/data/format/json.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/data/format/json.lux')
-rw-r--r--stdlib/source/lux/data/format/json.lux57
1 files changed, 1 insertions, 56 deletions
diff --git a/stdlib/source/lux/data/format/json.lux b/stdlib/source/lux/data/format/json.lux
index d7469e24b..2e31a3924 100644
--- a/stdlib/source/lux/data/format/json.lux
+++ b/stdlib/source/lux/data/format/json.lux
@@ -14,7 +14,6 @@
(text ["l" lexer])
[number "Real/" Codec<Text,Real>]
maybe
- [char "Char/" Codec<Text,Char>]
["R" result]
[sum]
[product]
@@ -426,57 +425,6 @@
[text? text! Text text;Eq<Text> text;encode #String "string" id]
)
-(def: #export (char json)
- {#;doc "Reads a JSON value as a single-character string."}
- (Parser Char)
- (case json
- (#String input)
- (case (Char/decode (format "#\"" input "\""))
- (#R;Success value)
- (#R;Success value)
-
- (#R;Error _)
- (#R;Error (format "Invalid format for char: " input)))
-
- _
- (#R;Error (format "JSON value is not a " "string" ": " (show-json json)))))
-
-(def: #export (char? test json)
- {#;doc "Asks whether a JSON value is a single-character string with the specified character."}
- (-> Char (Parser Bool))
- (case json
- (#String input)
- (case (Char/decode (format "#\"" input "\""))
- (#R;Success value)
- (if (:: char;Eq<Char> = test value)
- (#R;Success true)
- (#R;Error (format "Value mismatch: "
- (:: char;Codec<Text,Char> encode test) "=/=" (:: char;Codec<Text,Char> encode value))))
-
- (#R;Error _)
- (#R;Error (format "Invalid format for char: " input)))
-
- _
- (#R;Error (format "JSON value is not a " "string" ": " (show-json json)))))
-
-(def: #export (char! test json)
- {#;doc "Ensures a JSON value is a single-character string with the specified character."}
- (-> Char (Parser Unit))
- (case json
- (#String input)
- (case (Char/decode (format "#\"" input "\""))
- (#R;Success value)
- (if (:: char;Eq<Char> = test value)
- (#R;Success [])
- (#R;Error (format "Value mismatch: "
- (:: char;Codec<Text,Char> encode test) "=/=" (:: char;Codec<Text,Char> encode value))))
-
- (#R;Error _)
- (#R;Error (format "Invalid format for char: " input)))
-
- _
- (#R;Error (format "JSON value is not a " "string" ": " (show-json json)))))
-
(def: #export (nullable parser)
{#;doc "A parser that can handle the presence of null values."}
(All [a] (-> (Parser a) (Parser (Maybe a))))
@@ -767,7 +715,6 @@
[Bool poly;bool ;;gen-boolean]
[Int poly;int (|>. ;int-to-real ;;gen-number)]
[Real poly;real ;;gen-number]
- [Char poly;char (|>. char;as-text ;;gen-string)]
[Text poly;text ;;gen-string])]
($_ macro;either
<basic>
@@ -902,7 +849,6 @@
[Bool poly;bool ;;bool]
[Int poly;int ;;int]
[Real poly;real ;;real]
- [Char poly;char ;;char]
[Text poly;text ;;text])
<complex> (do-template [<type> <matcher> <decoder>]
[(do @
@@ -1055,12 +1001,11 @@
#bool Bool
#int Int
#real Real
- #char Char
#text Text
#maybe (Maybe Int)
#list (List Int)
#variant Variant
- #tuple [Int Real Char]
+ #tuple [Int Real Text]
#dict (Dict Text Int)})
(derived: (Codec<JSON,?> Record)))}