-
Notifications
You must be signed in to change notification settings - Fork 223
Decode map keys into keywords for [:map schemas in json-transformer
#1135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
15b56d0
1abc8e3
7d44b1c
cb8e7f7
761d62f
5b1dbaf
6a1f515
3c9ab67
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -415,6 +415,8 @@ | |
| (-transform-if-valid key-schema) | ||
| (-transform-map-keys)) | ||
| (-transform-map-keys m/-keyword->string))))}) | ||
| (assoc :map {:compile (fn [_ _] | ||
| (-transform-map-keys -string->keyword))}) | ||
|
||
| (cond-> json-vectors (assoc :vector -sequential->vector))) | ||
| :encoders (-json-encoders)}))) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -997,6 +997,18 @@ | |
| (mt/key-transformer | ||
| {:decode #(-> % name (str "_key") keyword)})))) | ||
|
|
||
| (testing "JSON transformer decodes map schema keys" | ||
| (let [schema [:map | ||
| [:a :uuid] | ||
|
||
| [:b [:enum :x :y :z]]] | ||
|
||
| value {"a" "b699671c-d34d-b33f-1337-dbdbfd337e73" | ||
| "b" "x"} | ||
| decoded-value (m/decode schema value mt/json-transformer)] | ||
| (is (= {:a #uuid "b699671c-d34d-b33f-1337-dbdbfd337e73" | ||
| :b :x} | ||
| decoded-value)) | ||
| (is (m/validate schema decoded-value)))) | ||
|
|
||
| (is (= {:x 32} | ||
| (m/decode | ||
| [:map {:decode/string '{:enter #(update % :x inc), :leave #(update % :x (partial * 2))}} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is now nested under the
:gen/fmapchange, even though it's not related. Please add it as a top-level bullet point at the top of the list.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to top-level + no longer labeled as breaking.