Inserting data into postgresql json columns using clojure.java.jdbc
Since clojure.java.jdbc exposes a few protocols, including clojure.java.jdbc/ISQLValue
, you can extend it to allow supplying json as an ordinary clojure map. Travis Vachon provides a thorough explanation of this process and a code snippet implementing it.
I also found a library, clj-postgresql, which implements lots of extra postgres functionality, including json and jsonb data types. You can simply require clj-postgresql.types
and json support will be imported.