There are about a dozen JSON packages on Hackage for Haskell. How do I know which package I should use? How do I get a popular opinion?
Are there any statistics on which package is being used the most, downloaded the most, etc.?
The other answers are obsolete I think, today it is widely accepted I think that the best JSON library and the de-facto standard in Haskell is Aeson:
http://hackage.haskell.org/package/aeson
The maintainer is Brian O'Sullivan, known for his deep knowledge of Haskell and his performance-oriented work; there is no question it's the right choice.
In addition Aeson offers a very nice API, check this example.
Also, I don't know for the past but nowadays also Yesod uses Aeson:
http://hackage.haskell.org/packages/archive/yesod-json/1.1.0/doc/html/Yesod-Json.html "using the aeson package"
http://www.yesodweb.com/book/json-web-service "We'll be using aeson for JSON parsing and rendering"
Choose by others' dependencies
If you use one of the new Haskell web frameworks, you may consider using the same json library as the framework is using. From the reverse dependencies it seems that the pairing is:
- Yesod:
JSONb
- Happstack:
RJson
- On-a-Horse: ???
And a lot of packages use json
.
Choose by features
You may also choose to use a package according to its features.
Consider using JSONb
if you are a ByteStrings' user. It uses AttoParsec instead of the usual Parsec, so it might be faster (but measure it first).
RJson
is doing some clever tricks to serialize nested records automatically.
YAJL
offers bindings to yajl, a fast parser written in C. But be careful: the original yajl is BSD, but Haskell YAJL is GPL-v3.
json
is, probably, a safe choice.
According to this list, RJson
has been downloaded more often than json
, but json
is by far the most used by other libraries on Hackage, with 77 reverse dependencies (33 direct and 44 indirect), versus 5 for JSONb
in second.
来源:https://stackoverflow.com/questions/3663550/which-haskell-package-for-json