Lars Trieloff Lars Trieloff - 6 months ago 22
JSON Question

How to choose a Clojure JSON library

There are multiple JSON parser/writer libraries available for Clojure, including:



What are the pros and cons of each, especially regarding speed, memory footprint, and programming convenience? Are there any other important factors to consider?

Answer

I decided to run a little shootout (the link is to results and the code used to test).

In terms of speed, clj-json is the fastest, 1.7x cheshire, and 5.6x clojure.data.json for a simple parse/generate task.

clojure.data.json has the smallest footprint, and clj-json and cheshire follow. cheshire has some superb features, though, and is my preferred library for dealing with JSON. You get support for SMILE, as well as a lovely interface for interpreting JSON (adding types, special rules on keys, etc) and custom encoders (the last also found in clojure.data.json).

Comments