Muuntaja, a content negotiation & formatting library for Clojure

Happy to announce [metosin/muuntaja "0.6.0-alpha1"], a content negotiation & formatting library for Clojure. Can be used both as a standalone lib or with Ring/Pedestal style web apps.

blogged: https://www.metosin.fi/blog/muuntaja/

It’s an alpha release, we are hoping to get feedback and testing on the changes before finalizing. The biggest changes:

  • change default JSON formatter from Cheshire to Jsonista
  • change the api to create new formats (with fail-fast assertions on the old syntax)
  • supports writing to byte-arrays (enabling NIO)
  • a multi-module layout, with YAML and MessagePack as separate modules

a quick sample:

(require '[muuntaja.core :as m])

(def m (m/create))

(m/encodes m)
; #{"application/json"
;   "application/transit+msgpack"
;   "application/transit+json"
;   "application/edn"}

(m/decodes m)
; #{"application/json"
;   "application/transit+msgpack"
;   "application/transit+json"
;   "application/edn"}

(->> {:olipa "kerran"}
     (m/encode m "application/json"))
; #object[java.io.ByteArrayInputStream]

(->> {:olipa "kerran"}
     (m/encode m "application/json")
     (slurp))
; "{\"olipa\":\"kerran\"}"

(->> {:olipa "kerran"}
     (m/encode m "application/json")
     (m/decode m "application/json"))
; {:olipa "kerran"}

coordinates:

6 Likes

thank you! happy user so far :).

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.