ring-clojure / ring-json

Ring middleware for handling JSON
313 stars 47 forks source link

Feature request: allow :key-fn function to convert map keys (feature) #62

Open tzafrirben opened 4 years ago

tzafrirben commented 4 years ago

Most of the times I use kebab-case keys for maps. In JavaScript, kebab-case is not well supported and t is most common to use camelCase for JSON object keys.

When writing REST API, mainly when the client is not implemented in Clojure, the body JSON object keys are camelCase and it will be nice to be able to convert it to kebab-case when serializing the request.

{"firstName":"John", "lastName":"Doe"} -> {:first-name: "John" :last-name "Doe"}

It will be helpful to provide some kind of key converter function (i.e :key-fn) or provide a JSON serializer function as a dependency.

I hope it makes sense not only to me...