-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add mechanism to enable Jackson Features #95
Comments
There seem to be at least the following type of features, that all can be configured in the I think it would be good to be able to set any of these easily. option 1: document how to do this the Java-way
(def mapper
(doto (j/object-mapper)
(.enable JsonParser$Feature/ALLOW_UNQUOTED_CONTROL_CHARS)))
(def muuntaja
(m/create
(assoc-in
m/default-options
[:formats "application/json" :opts]
{:mapper mapper})))
option 2: make it easier
(j/object-mapper {:features [JsonParser$Feature/ALLOW_UNQUOTED_CONTROL_CHARS ...]})
(def muuntaja
(m/create
(assoc-in
m/default-options
[:formats "application/json" :opts]
{:features [JsonParser$Feature/ALLOW_UNQUOTED_CONTROL_CHARS ...]}))) option 3: all-clojure
(j/object-mapper {:features #{:json-parser/allow-unquoted-control-chars ...}})
(def muuntaja
(m/create
(assoc-in
m/default-options
[:formats "application/json" :opts]
{:features #{:json-parser/allow-unquoted-control-chars ...}}))) thoughts? |
I thought about option 1 but it will silently ignore other keys in https://github.com/metosin/muuntaja/blob/master/modules/muuntaja/src/muuntaja/format/json.clj#L13 |
Currently, the API does not expose a way to enable
jackson
's encoder/decoder features. It looks like the only way to do this is through the:mapper
key in[:formats "application/json" :decoder-opts]
or[:formats "application/json" :encoder-opts]
.Use case example:
For compatibility, I would like to enable
com.fasterxml.jackson.core.JsonParser.Feature/ALLOW_UNQUOTED_CONTROL_CHARS
I think some change in
jsonista
is required to support this.I propose adding an option key, maybe named
features
, where library consumer can pass a map of features.jsonista
can then call.configure
on each item. Or the features could be translated to clojure keywords.Example:
I can create PR if the proposal is blessed. Thanks!
The text was updated successfully, but these errors were encountered: