This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-26
Channels
- # asami (3)
- # babashka (3)
- # beginners (45)
- # boot (3)
- # calva (6)
- # clojure (26)
- # clojure-dev (16)
- # clojure-europe (15)
- # clojure-norway (6)
- # clojure-uk (6)
- # clojurescript (34)
- # community-development (4)
- # conjure (3)
- # datascript (4)
- # datomic (4)
- # emacs (21)
- # events (1)
- # fulcro (16)
- # graalvm (5)
- # jackdaw (1)
- # kaocha (5)
- # lsp (74)
- # malli (8)
- # nbb (37)
- # off-topic (50)
- # pathom (5)
- # reagent (19)
- # ring (1)
- # shadow-cljs (60)
- # sql (3)
I am surprised by how JSON transformer works
(m/decode :int "123" malli.transform/json-transformer) ;; => "123"
Why isn’t the string "123"
converted to an integer?
In the same way,
(m/decode [:map [:foo :int]] {:foo "123"} malli.transform/json-transformer) ;; => {:foo "123"}
malli.transform/-json-decoders
doesn't have a string->double
thingy
maybe you want to be looking at malli.transform/string-transformer
instead?
The distinction between json-decoders and string-decoders is not 100% clear to me
My impression is that string-transformer is for parsing string-based values, and json-transformer for enriching values from already-parsed json with JVM/clj types (uuid, date, keyword etc) not present in json So it might make sense to compose string-transformer with json-transformer
It makes sense to me also
@U45T93RA6 Is there a transformer that keywordize map keys when the schema keys are keywords?
I have a list of keyseqs [[:parent :child1 :child2]...]
that map in a human readable way into my schema, but when i do mu/get-in mu/update-in the mappings don't work. when i do subschemas the paths are sorta like [:parent 0 0 :child1 0 0 :child2]
and :parent will have 10 different paths to the same :child1 and :child2. it seems a bit like a flip of a coin if i get the correct path or not. i've tried a few different ways of figuring out the correct one (smallest count). also the :in and :path are different, and i'm not sure what to use in mu/update-in. unfortunately i'm not in control of the schema (it's generated based off of json-schema). my next approach will involve recursive mu/find-in
, but i'm wondering if anyone has run into a problem like this before, where conceptual indexing and real malli indexing have a significant mismatch and how to get to the correct spots in the schema to programmatically edit it (i'm adding custom properties)