我有一个UUID和
java util日期,它将文字作为#uuid和#inst,如何在不引用文字本身的情况下指定uuid或日期?
clj-json不喜欢处理它们,当我尝试生成字符串时最终会抛出错误
clj-json不喜欢处理它们,当我尝试生成字符串时最终会抛出错误
{:timestamp (java.util.Date.)} ;{:timestamp #inst "2013-05-17T13:45:24.095-00:00"} ;but as a string the date changes format {:timestamp (str (java.util.Date.))} {:timestamp "Fri May 17 09:45:44 EDT 2013"} (json/generate-string {:uuid (java.util.UUID/randomUUID)}) ;#uuid "d66cf77f-13b6-4291-95cd-c2bb40aa36b3" java.lang.Exception: Cannot generate d66cf77f-13b6-4291-95cd-c2bb40aa36b3 JsonExt.java:96 clj_json.JsonExt$Generator.generate JsonExt.java:83 clj_json.JsonExt$Generator.generate JsonExt.java:103 clj_json.JsonExt.generate core.clj:18 clj-json.core/generate-to-writer core.clj:26 clj-json.core/generate-string NO_SOURCE_FILE:32 myapp.handler/eval8390
解决方法
不确定,但它看起来像你需要的:
user=> (str (java.util.UUID/randomUUID)) "91d7fcc5-d24d-4e33-a111-6ba69d14eb6a"
对于日期,您需要选择正确的格式.即:
user=> (import java.text.SimpleDateFormat) java.text.SimpleDateFormat user=> (.format (SimpleDateFormat. "yyyy/MM/dd HH:mm:ss") (java.util.Date.)) "2013/05/17 16:49:58"