noir-clojure / lib-noir

A set of libraries for ring apps, including stateful sessions.
Eclipse Public License 1.0
479 stars 47 forks source link

Option to use cheshire.custom/generate-string in noir.response/json #2

Closed solussd closed 11 years ago

solussd commented 12 years ago

Currently there is no way to use a custom (json) encoder with noir.response/json. Using cheshire.custom/generate-string (instead of cheshire.core/generate-string) lets me add custom encoders for unsupported types, e.g.:

(cheshire.custom/add-encoder org.bson.types.ObjectId (fn [o json-generator] (.writeString json-generator (str o))))
(cheshire.custom/generate-string (org.bson.types.ObjectId.))
; => "\"4ff3648fc2e6638a4552a80b\""
Raynes commented 11 years ago

This was done a while ago.

solussd commented 11 years ago

Excellent, thanks.