metosin/jsonista

Name: jsonista

Owner: Metosin

Description: Clojure library for fast JSON encoding and decoding.

Created: 2017-05-23 13:34:37.0

Updated: 2018-05-23 18:47:03.0

Pushed: 2018-05-23 18:47:02.0

Homepage:

Size: 377

Language: Clojure

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

jsonista Continuous Integration status

jsonissa / jsonista / jsoniin, jsonilla / jsonilta / jsonille

Clojure library for fast JSON encoding and decoding.

Much faster than Cheshire while still having all the necessary features for web development. Designed for use with Muuntaja.

Blogged:

Latest version

Clojars Project

Requires Java1.8+

Quickstart
uire '[jsonista.core :as j])

rite-value-as-string {"hello" 1})
> "{\"hello\":1}"

ead-value *1)
> {"hello" 1}
Examples

Changing how map keys are encoded & decoded:

n reverse-string [s] (apply str (reverse s)))

 mapper
/object-mapper
{:encode-key-fn (comp reverse-string name)
 :decode-key-fn (comp keyword reverse-string)}))

{:kikka "kukka"}
(doto prn)
(j/write-value-as-string mapper)
(doto prn)
(j/read-value mapper)
(prn))
kikka "kukka"}
\"akkik\":\"kukka\"}"
kikka "kukka"}

Reading & writing directly into a file:

 file (java.io.File. "hello.json"))

rite-value file {"hello" "world"})

rp file)
> "{\"hello\":\"world\"}"

ead-value file)
> {"hello" "world"}

Adding support for joda-time Classes, used by clj-time.

com.fasterxml.jackson.datatype/jackson-datatype-joda "2.9.5"]
ort '[com.fasterxml.jackson.datatype.joda JodaModule])
ort '[org.joda.time LocalDate])

 mapper
/object-mapper
{:modules [(JodaModule.)]}))

rite-value-as-string (LocalDate. 0) mapper)
"1970-01-01\""
Performance

See perf-tests for details.

encode

decode

License

Copyright © 2016-2018 Metosin Oy.

Distributed under the Eclipse Public License, the same as Clojure.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.