Clojure's transit不支持开箱即用的 Joda 时间格式。如何添加对 org.joda.time.DateTime
的写入支持?
最佳答案
添加此功能:
(def joda-time-writer
(transit/write-handler
(constantly "m")
#(-> % coerce/to-date .getTime)
#(-> % coerce/to-date .getTime .toString)))
并像这样使用它:
(transit/writer out :json
{:handlers {org.joda.time.DateTime joda-time-writer}})
关于clojure - Clojure 中 Joda 时间的自定义 Transit 编写器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25575373/