Skip to content

Instantly share code, notes, and snippets.

@lynaghk
Created April 12, 2013 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lynaghk/5374327 to your computer and use it in GitHub Desktop.
Save lynaghk/5374327 to your computer and use it in GitHub Desktop.
Cheshire encode-map bug.
(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