Created
April 12, 2013 19:06
-
-
Save lynaghk/5374327 to your computer and use it in GitHub Desktop.
Cheshire encode-map bug.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns cheshire-test ;;this is cheshire 5.1.0 | |
(:require [cheshire | |
[core :as json] | |
[generate :refer [add-encoder encode-map]]])) | |
(json/generate-string {:x (java.util.Date.)}) ;;works fine: {"x":"2013-04-12T19:05:54Z"} | |
;;I want to print out dates as {"#inst":"2013-04-12T19:05:54Z"} | |
(add-encoder java.util.Date | |
(fn [date json-generator] | |
(encode-map {"inst" (subs (pr-str date) 7 36)} | |
json-generator))) | |
(json/generate-string {:x (java.util.Date.)}) ;;BOOM! Wrong number of args (4) passed to: generate$generate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment