Skip to content

Commit

Permalink
Merge pull request #234 from tuliolima/feat/supporting_newer_data_jso…
Browse files Browse the repository at this point in the history
…n_versions

Feat: supporting 3-ary clojure.data.json/write in newer versions
  • Loading branch information
michaelklishin committed Apr 8, 2024
2 parents 84170f7 + 5852a5f commit 182a3a6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion project.clj
Expand Up @@ -36,7 +36,7 @@
:dev {:resource-paths ["test/resources"] :dev {:resource-paths ["test/resources"]
:dependencies [[clj-time "0.15.1" :exclusions [org.clojure/clojure]] :dependencies [[clj-time "0.15.1" :exclusions [org.clojure/clojure]]
[cheshire "5.8.1" :exclusions [org.clojure/clojure]] [cheshire "5.8.1" :exclusions [org.clojure/clojure]]
[org.clojure/data.json "0.2.6" :exclusions [org.clojure/clojure]] [org.clojure/data.json "2.5.0" :exclusions [org.clojure/clojure]]
[org.clojure/tools.cli "0.4.1" :exclusions [org.clojure/clojure]] [org.clojure/tools.cli "0.4.1" :exclusions [org.clojure/clojure]]
[org.clojure/core.cache "0.7.1" :exclusions [org.clojure/clojure]] [org.clojure/core.cache "0.7.1" :exclusions [org.clojure/clojure]]
[ring/ring-core "1.7.1" :exclusions [org.clojure/clojure]] [ring/ring-core "1.7.1" :exclusions [org.clojure/clojure]]
Expand Down
14 changes: 10 additions & 4 deletions src/clojure/monger/json.clj
Expand Up @@ -70,13 +70,19 @@
(try (try
(extend-protocol clojure.data.json/JSONWriter (extend-protocol clojure.data.json/JSONWriter
ObjectId ObjectId
(-write [^ObjectId object out] (-write
(clojure.data.json/write (.toString object) out))) ([^ObjectId object out]
(clojure.data.json/write (.toString object) out))
([^ObjectId object out options]
(clojure.data.json/write (.toString object) out options))))


(extend-protocol clojure.data.json/JSONWriter (extend-protocol clojure.data.json/JSONWriter
BSONTimestamp BSONTimestamp
(-write [^BSONTimestamp object out] (-write
(clojure.data.json/write {:time (.getTime object) :inc (.getInc object)} out))) ([^BSONTimestamp object out]
(clojure.data.json/write {:time (.getTime object) :inc (.getInc object)} out))
([^BSONTimestamp object out options]
(clojure.data.json/write {:time (.getTime object) :inc (.getInc object)} out options))))


(catch Throwable _ (catch Throwable _
false)) false))
Expand Down

0 comments on commit 182a3a6

Please sign in to comment.