ngrunwald / ring-middleware-format

Ring middleware for parsing parameters and emitting responses in JSON or other formats
163 stars 49 forks source link

:key-fn set to true for json param serialization #56

Closed bramkoot closed 8 years ago

bramkoot commented 8 years ago

I was looking into the options of transforming the incoming keys using the format-options, but for some reason the :key-fn option for the json-parsing is made unavailable. Could someone explain why this is?

The overwriting of the :key-fn option happens on line 147 of format_params.clj: https://github.com/ngrunwald/ring-middleware-format/blob/master/src/ring/middleware/format_params.clj#L147

This code calls the make-json-decoder, but for some reason overwrites the :key-fn with true: (make-json-decoder (assoc options :key-fn true))

Deraen commented 8 years ago

You should be able to use :key-fn with wrap-json-params aka. :json format, not :json-kw.

:json-kw version exists partly for legacy reasons and the fact that it overwrites :key-fn is just a bug which I didn't catch when I introduced option to set key-fn: https://github.com/ngrunwald/ring-middleware-format/commit/245aa85fccffae8fdbc577ef7b877e5a562ffd91

Deraen commented 7 years ago

I released a new version with the fix.