diff options
author | Eduardo Julian | 2021-09-12 00:07:08 -0400 |
---|---|---|
committer | Eduardo Julian | 2021-09-12 00:07:08 -0400 |
commit | dda05bca0956af5e5b3875c4cc36e61aa04772e4 (patch) | |
tree | 0f8b27697d58ab5c8e41aba7c7c9f769d3800767 /stdlib/source/library/lux/data/format/json.lux | |
parent | d48270f43c404ba19ca04da2553455ecaaf2caba (diff) |
Made the "#" character great again!
Diffstat (limited to 'stdlib/source/library/lux/data/format/json.lux')
-rw-r--r-- | stdlib/source/library/lux/data/format/json.lux | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/stdlib/source/library/lux/data/format/json.lux b/stdlib/source/library/lux/data/format/json.lux index f29042a83..734a38177 100644 --- a/stdlib/source/library/lux/data/format/json.lux +++ b/stdlib/source/library/lux/data/format/json.lux @@ -60,12 +60,12 @@ (def: .public null? (Predicate JSON) - (|>> (case> #Null true + (|>> (case> {#Null} true _ false))) (def: .public object (-> (List [String JSON]) JSON) - (|>> (dictionary.of_list text.hash) #..Object)) + (|>> (dictionary.of_list text.hash) {..#Object})) (type: JSON' (Rec JSON' @@ -83,7 +83,7 @@ (<>.rec (function (_ jsonP) ($_ <>.or - (<code>.local_tag! "null") + (<code>.form (<>\in [])) <code>.bit <code>.frac <code>.text @@ -98,20 +98,20 @@ (-> JSON' Code) (case token {#Null' _} - (` #..Null) + (` {..#Null}) (^template [<ctor> <input_tag> <output_tag>] [{<input_tag> value} (` {<output_tag> (~ (<ctor> value))})]) - ([code.bit #..Boolean' #..Boolean] - [code.frac #..Number' #..Number] - [code.text #..String' #..String]) + ([code.bit ..#Boolean' ..#Boolean] + [code.frac ..#Number' ..#Number] + [code.text ..#String' ..#String]) {#Array' members} - (` {#..Array ((~! row.row) (~+ (row.list (row\each jsonF members))))}) + (` {..#Array ((~! row.row) (~+ (row.list (row\each jsonF members))))}) {#Object' pairs} - (` {#..Object ((~! dictionary.of_list) + (` {..#Object ((~! dictionary.of_list) (~! text.hash) (list (~+ (|> pairs dictionary.entries @@ -128,46 +128,46 @@ (-> JSON (Try (List String))) (case json {#Object obj} - {#try.Success (dictionary.keys obj)} + {try.#Success (dictionary.keys obj)} _ - {#try.Failure ($_ text\composite "Cannot get the fields of a non-object.")})) + {try.#Failure ($_ text\composite "Cannot get the fields of a non-object.")})) (def: .public (field key json) (-> String JSON (Try JSON)) (case json {#Object obj} (case (dictionary.value key obj) - {#.Some value} - {#try.Success value} + {.#Some value} + {try.#Success value} - #.None - {#try.Failure ($_ text\composite "Missing field '" key "' on object.")}) + {.#None} + {try.#Failure ($_ text\composite "Missing field '" key "' on object.")}) _ - {#try.Failure ($_ text\composite "Cannot get field '" key "' on a non-object.")})) + {try.#Failure ($_ text\composite "Cannot get field '" key "' on a non-object.")})) (def: .public (has key value json) (-> String JSON JSON (Try JSON)) (case json {#Object obj} - {#try.Success {#Object (dictionary.has key value obj)}} + {try.#Success {#Object (dictionary.has key value obj)}} _ - {#try.Failure ($_ text\composite "Cannot set field '" key "' on a non-object.")})) + {try.#Failure ($_ text\composite "Cannot set field '" key "' on a non-object.")})) (template [<name> <tag> <type>] [(def: .public (<name> key json) (-> Text JSON (Try <type>)) (case (field key json) - {#try.Success {<tag> value}} - {#try.Success value} + {try.#Success {<tag> value}} + {try.#Success value} - {#try.Success _} - {#try.Failure ($_ text\composite "Wrong value type at key: " key)} + {try.#Success _} + {try.#Failure ($_ text\composite "Wrong value type at key: " key)} - {#try.Failure error} - {#try.Failure error}))] + {try.#Failure error} + {try.#Failure error}))] [boolean_field #Boolean Boolean] [number_field #Number Number] @@ -181,7 +181,7 @@ (def: (= x y) (case [x y] - [#Null #Null] + [{#Null} {#Null}] #1 (^template [<tag> <struct>] @@ -208,8 +208,8 @@ (list\mix (function (_ [xk xv] prev) (and prev (case (dictionary.value xk ys) - #.None #0 - {#.Some yv} (= xv yv)))) + {.#None} #0 + {.#Some yv} (= xv yv)))) #1 (dictionary.entries xs))) @@ -352,10 +352,10 @@ offset (<text>.many <text>.decimal)] (in ($_ text\composite mark (if signed?' "-" "") offset))))] (case (f\decoded ($_ text\composite (if signed? "-" "") digits "." decimals exp)) - {#try.Failure message} + {try.#Failure message} (<>.failure message) - {#try.Success value} + {try.#Success value} (in value)))) (def: escaped_parser |