All Projects → metosin → Jsonista

metosin / Jsonista

Licence: epl-2.0
Clojure library for fast JSON encoding and decoding.

Programming Languages

clojure
4091 projects

Projects that are alternatives of or similar to Jsonista

Jsonj
A fluent Java API for manipulating json data structures
Stars: ✭ 42 (-85.52%)
Mutual labels:  json, jackson
Json Schema Validator
A fast Java JSON schema validator that supports draft V4, V6, V7 and V2019-09
Stars: ✭ 292 (+0.69%)
Mutual labels:  json, jackson
Easyjson
Provides an unified JSON access API, you can adapter any JSON library to Gson, Jackson, FastJson with easyjson。 提供了一个JSON门面库,就像slf4j一样。easyjson本身不做json的操作,完全依赖于底层实现库。可以直接使用Easyjson的API,底层的JSON库随时可切换。也可以使用其中某个json的API,然后通过easyjson适配给其他的json库
Stars: ✭ 54 (-81.38%)
Mutual labels:  json, jackson
Jsonschema2pojo
Generate Java types from JSON or JSON Schema and annotate those types for data-binding with Jackson, Gson, etc
Stars: ✭ 5,633 (+1842.41%)
Mutual labels:  json, jackson
Jackson Jq
jq for Jackson Java JSON Processor
Stars: ✭ 178 (-38.62%)
Mutual labels:  json, jackson
Jackson Module Kotlin
Module that adds support for serialization/deserialization of Kotlin (http://kotlinlang.org) classes and data classes.
Stars: ✭ 830 (+186.21%)
Mutual labels:  json, jackson
Kripton
A Java/Kotlin library for Android platform, to manage bean's persistence in SQLite, SharedPreferences, JSON, XML, Properties, Yaml, CBOR.
Stars: ✭ 110 (-62.07%)
Mutual labels:  json, jackson
Typescript Generator
Generates TypeScript from Java - JSON declarations, REST service client
Stars: ✭ 729 (+151.38%)
Mutual labels:  json, jackson
Jackson Datatype Money
Extension module to properly support datatypes of javax.money
Stars: ✭ 165 (-43.1%)
Mutual labels:  json, jackson
Jackson Core
Core part of Jackson that defines Streaming API as well as basic shared abstractions
Stars: ✭ 2,003 (+590.69%)
Mutual labels:  json, jackson
Jslt
JSON query and transformation language
Stars: ✭ 367 (+26.55%)
Mutual labels:  json, jackson
Bson4jackson
A pluggable BSON generator and parser for the Jackson JSON processor.
Stars: ✭ 244 (-15.86%)
Mutual labels:  json, jackson
Emfjson Jackson
JSON Binding for Eclipse Modeling Framework
Stars: ✭ 79 (-72.76%)
Mutual labels:  json, jackson
Gwt Jackson
gwt-jackson is a JSON parser for GWT. It uses Jackson 2.x annotations to customize the serialization/deserialization process.
Stars: ✭ 110 (-62.07%)
Mutual labels:  json, jackson
Stubbornjava
Unconventional Java code for building web servers / services without a framework. Think dropwizard but as a seed project instead of a framework. If this project had a theme it would be break the rules but be mindful of your decisions.
Stars: ✭ 184 (-36.55%)
Mutual labels:  json, jackson
Jackson Databind
General data-binding package for Jackson (2.x): works on streaming API (core) implementation(s)
Stars: ✭ 2,959 (+920.34%)
Mutual labels:  json, jackson
Slack History Export
A NPM module that allows slack users export their history
Stars: ✭ 284 (-2.07%)
Mutual labels:  json
I18n Editor
GUI for editing your i18n translation files
Stars: ✭ 290 (+0%)
Mutual labels:  json
Sq
swiss-army knife for data
Stars: ✭ 275 (-5.17%)
Mutual labels:  json
Korio
Korio: Kotlin cORoutines I/O : Virtual File System + Async/Sync Streams + Async TCP Client/Server + WebSockets for Multiplatform Kotlin 1.3
Stars: ✭ 282 (-2.76%)
Mutual labels:  json

jsonista Continuous Integration status cljdoc badge

jsonissa / jsonista / jsoniin, jsonilla / jsonilta / jsonille

Clojure library for fast JSON encoding and decoding.

Faster than data.json or Cheshire while still having the necessary features for web development. Designed for use with Muuntaja.

Blogged:

Latest version

Clojars Project

Requires Java1.8+

Quickstart

(require '[jsonista.core :as j])

(j/write-value-as-string {"hello" 1})
;; => "{\"hello\":1}"

(j/read-value *1)
;; => {"hello" 1}

Examples

Using explicit ObjectMapper:

(-> {:dog {:name "Teppo"}}
    (j/write-value-as-bytes j/default-object-mapper)
    (j/read-value j/default-object-mapper))
;; => {"dog" {"name" "Teppo"}}

Using keyword keys:

(-> {:dog {:name "Teppo"}}
    (j/write-value-as-bytes j/keyword-keys-object-mapper)
    (j/read-value j/keyword-keys-object-mapper))
;; => {:dog {:name "Teppo"}}

Changing how map keys are encoded & decoded:

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

(def mapper
  (j/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:

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

(j/write-value file {"hello" "world"})

(slurp file)
;; => "{\"hello\":\"world\"}"

(j/read-value file)
;; => {"hello" "world"}

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

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

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

(j/write-value-as-string (LocalDate. 0) mapper)
; "\"1970-01-01\""

Tagged JSON

Adding support for lossless encoding data using tagged values. This includes both reading and writing support.

(def mapper
  (j/object-mapper
    {:encode-key-fn true
     :decode-key-fn true
     :modules [(jt/module
                 {:handlers {Keyword {:tag "!kw"
                                      :encode jt/encode-keyword
                                      :decode keyword}
                             PersistentHashSet {:tag "!set"
                                                :encode jt/encode-collection
                                                :decode set}}})]}))

(-> {:system/status #{:status/good}}
    (j/write-value-as-string mapper)
    (doto prn)
    (j/read-value mapper))
; prints "{\"system/status\":[\"!set\",[[\"!kw\",\"status/good\"]]]}"
; => {:system/status #{:status/good}}

In simple perf tests, tagged JSON is much faster than EDN or Transit.

Performance

  • All standard encoders and decoders are written in Java
  • Protocol dispatch with read-value & write-value
  • Jackson ObjectMapper is used directly
  • Small functions to support JVM Inlining

Measured using lein-jmh, see perf-tests for details.

Throughput, relative

encode

decode

Throughput, absolute

encode

decode

Throughput, data

:benchmark                     :name    :mode        :samples  :score              :score-error  :params
-----------------------------  -------  -----------  --------  ------------------  ------------  --------------
jsonista.jmh/encode-data-json  :encode  :throughput  5         406998.934   ops/s  152242.102    {:size "10b"}
jsonista.jmh/encode-data-json  :encode  :throughput  5         146750.626   ops/s  13532.113     {:size "100b"}
jsonista.jmh/encode-data-json  :encode  :throughput  5         28543.913    ops/s  5982.429      {:size "1k"}
jsonista.jmh/encode-data-json  :encode  :throughput  5         1994.604     ops/s  193.798       {:size "10k"}
jsonista.jmh/encode-data-json  :encode  :throughput  5         229.534      ops/s  3.574         {:size "100k"}
jsonista.jmh/encode-cheshire   :encode  :throughput  5         1202854.746  ops/s  63201.698     {:size "10b"}
jsonista.jmh/encode-cheshire   :encode  :throughput  5         468291.944   ops/s  37267.515     {:size "100b"}
jsonista.jmh/encode-cheshire   :encode  :throughput  5         108479.571   ops/s  2483.284      {:size "1k"}
jsonista.jmh/encode-cheshire   :encode  :throughput  5         10293.254    ops/s  92.099        {:size "10k"}
jsonista.jmh/encode-cheshire   :encode  :throughput  5         1060.651     ops/s  4.026         {:size "100k"}
jsonista.jmh/encode-jsonista   :encode  :throughput  5         6783801.957  ops/s  54798.388     {:size "10b"}
jsonista.jmh/encode-jsonista   :encode  :throughput  5         2261881.877  ops/s  41683.847     {:size "100b"}
jsonista.jmh/encode-jsonista   :encode  :throughput  5         394457.058   ops/s  4225.290      {:size "1k"}
jsonista.jmh/encode-jsonista   :encode  :throughput  5         35557.637    ops/s  532.431       {:size "10k"}
jsonista.jmh/encode-jsonista   :encode  :throughput  5         3060.934     ops/s  101.250       {:size "100k"}
jsonista.jmh/encode-jackson    :encode  :throughput  5         6272986.538  ops/s  8067758.467   {:size "10b"}
jsonista.jmh/encode-jackson    :encode  :throughput  5         1554381.542  ops/s  2291008.911   {:size "100b"}
jsonista.jmh/encode-jackson    :encode  :throughput  5         275663.380   ops/s  258073.341    {:size "1k"}
jsonista.jmh/encode-jackson    :encode  :throughput  5         30998.301    ops/s  7629.493      {:size "10k"}
jsonista.jmh/encode-jackson    :encode  :throughput  5         2848.233     ops/s  248.972       {:size "100k"}
jsonista.jmh/decode-data-json  :decode  :throughput  5         910109.735   ops/s  5590.181      {:size "10b"}
jsonista.jmh/decode-data-json  :decode  :throughput  5         245111.831   ops/s  2604.368      {:size "100b"}
jsonista.jmh/decode-data-json  :decode  :throughput  5         42535.710    ops/s  647.046       {:size "1k"}
jsonista.jmh/decode-data-json  :decode  :throughput  5         3705.661     ops/s  21.401        {:size "10k"}
jsonista.jmh/decode-data-json  :decode  :throughput  5         412.894      ops/s  4.897         {:size "100k"}
jsonista.jmh/decode-cheshire   :decode  :throughput  5         1440650.958  ops/s  63665.904     {:size "10b"}
jsonista.jmh/decode-cheshire   :decode  :throughput  5         538246.521   ops/s  5078.053      {:size "100b"}
jsonista.jmh/decode-cheshire   :decode  :throughput  5         110073.963   ops/s  4482.999      {:size "1k"}
jsonista.jmh/decode-cheshire   :decode  :throughput  5         9422.709     ops/s  763.989       {:size "10k"}
jsonista.jmh/decode-cheshire   :decode  :throughput  5         991.322      ops/s  65.215        {:size "100k"}
jsonista.jmh/decode-jsonista   :decode  :throughput  5         2463256.808  ops/s  233941.924    {:size "10b"}
jsonista.jmh/decode-jsonista   :decode  :throughput  5         606524.401   ops/s  24347.671     {:size "100b"}
jsonista.jmh/decode-jsonista   :decode  :throughput  5         143850.780   ops/s  26755.413     {:size "1k"}
jsonista.jmh/decode-jsonista   :decode  :throughput  5         13433.671    ops/s  1946.566      {:size "10k"}
jsonista.jmh/decode-jsonista   :decode  :throughput  5         1214.055     ops/s  204.500       {:size "100k"}
jsonista.jmh/decode-jackson    :decode  :throughput  5         6098939.624  ops/s  768530.918    {:size "10b"}
jsonista.jmh/decode-jackson    :decode  :throughput  5         1435602.777  ops/s  20860.504     {:size "100b"}
jsonista.jmh/decode-jackson    :decode  :throughput  5         274066.827   ops/s  2922.479      {:size "1k"}
jsonista.jmh/decode-jackson    :decode  :throughput  5         25650.308    ops/s  1388.505      {:size "10k"}
jsonista.jmh/decode-jackson    :decode  :throughput  5         2569.702     ops/s  13.894        {:size "100k"}

License

Copyright © 2016-2020 Metosin Oy.

Distributed under the Eclipse Public License 2.0.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].