JSON encoding and decoding function construction with support for configurable key conversion.
Supports:
org.joda.time
and java.time
typesAdd the following to your project.clj
file:
[b-social/jason "0.1.2"]
(require '[jason.core :refer [defcoders] :as jason])
(require '[camel-snake-kebab.core :refer [->snake_case_string
->snake_case_keyword]])
(defcoders wire)
(defcoders db
:encode-key-fn (jason/->encode-key-fn ->snake_case_string)
:decode-key-fn (jason/->decode-key-fn ->snake_case_keyword))
(->wire-json {:first-name "Jess"})
;; => "{\"firstName\": \"Jess\"}"
(->db-json {:first-name "Jess"})
;; => "{\"first_name\": \"Jess\"}"
(<-wire-json "{\"firstName\": \"Jess\"}")
;; => {:first-name "Jess"}
(<-db-json "{\"first_name\": \"Jess\"}")
;; => {:first_name "Jess"}
See the Getting Started guide for more details.
Copyright © 2018 B-Social Ltd.
Distributed under the terms of the MIT License.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close