Fork me on GitHub
#malli
<
2021-08-21
>
ikitommi04:08:42

yes, transformers know that, quick hack would be to loop the registered keys of json-transformer or even ask if there is anything to do:

(= identity
   (m/decoder
    schema
    (mt/json-transformer))

Ben Sless10:08:02

Some perf finding: invoking map on arguments is the shortest path to .valAt without interop. Faster than get

👍 2
dominicm14:08:37

@ikitommi That doesn't quite work:

(m/decoder
    [:map [{"type" "foo"} string?]]
    (malli.transform/json-transformer))
Which can't be encoded as valid JSON.

dominicm14:08:50

heh, jsonista converts the key to a edn string in that case: "{\"{\\\"type\\\" \\\"foo\\\"}\":\"bar\"}"

ikitommi14:08:47

@dominicm right, there is no decoders registered for keys in json-transformer, it's expected to come clean from actual JSON decoder. And same for encoding, malli doesn't have JSON encoders for all schemas, as in the actual encoder (jsonista, Cheshire etc) already does that.

👍 2
Ben Sless16:08:05

Opened a bunch of small PRs relating to https://github.com/metosin/malli/issues/513 . I broke them down as much as possible to find the best performance gains for each change and to cover enough use cases in the benchmarks. Didn't want to end up accidentally slowing down one while speeding up the other (which I did, initially)