如何选择Clojure JSON库

时间:2021-03-05 22:53:03

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

Clojure有多个JSON解析器/编写器库,包括:

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

每种方法的优缺点是什么,特别是在速度,内存占用和编程方便性方面?还有其他重要因素需要考虑吗?

1 个解决方案

#1


17  

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.

就速度而言,clj-json是最快的,1.7x cheshire,以及5.6x clojure.data.json,用于简单的解析/生成任务。

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).

clojure.data.json占地面积最小,clj-json和cheshire紧随其后。但是,cheshire有一些很棒的功能,是我处理JSON的首选库。您可以获得对SMILE的支持,以及用于解释JSON(添加类型,键上的特殊规则等)和自定义编码器(最后也可以在clojure.data.json中找到)的可爱界面。

#1


17  

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.

就速度而言,clj-json是最快的,1.7x cheshire,以及5.6x clojure.data.json,用于简单的解析/生成任务。

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).

clojure.data.json占地面积最小,clj-json和cheshire紧随其后。但是,cheshire有一些很棒的功能,是我处理JSON的首选库。您可以获得对SMILE的支持,以及用于解释JSON(添加类型,键上的特殊规则等)和自定义编码器(最后也可以在clojure.data.json中找到)的可爱界面。