What is the most mature JSON library for Erlang

2020-01-31 03:22发布

I wanted to use YAML but there is not a single mature YAML library for Erlang. I know there are a few JSON libraries, but was wondering which is the most mature?

标签: json erlang
6条回答
相关推荐>>
2楼-- · 2020-01-31 03:34

My favourite is mochijson2. The API is straightforward, it's fast enough for me (I never actually bothered to benchmark it though, to be honest--I'm mostly en- and de-coding small packets), and I've been using it in a stable "production server" for a year now or so. Just remember to install mochinum as well, mochijson2 uses it to encode large numbers, if you miss it, and you'll try to encode a large number, it will throw an exception.

See also: mochijson2 examples (stackoverflow)

查看更多
啃猪蹄的小仙女
3楼-- · 2020-01-31 03:37

Also check out jsx. "An erlang application for consuming, producing and manipulating json. Inspired by Yajl." I haven't tried it myself yet, but it looks promising.

As a side note; I found this library through Jesse, a json schema validator by Klarna.

查看更多
The star\"
4楼-- · 2020-01-31 03:39

Have a look at the one from mochiweb: mochijson.erl

1> mochijson:decode("{\"Name\":\"Tom\",\"Age\":10}").   
{struct,[{"Name","Tom"},{"Age",10}]}
查看更多
仙女界的扛把子
5楼-- · 2020-01-31 03:43

Trapexit offers a really cool search feature for Erlang projects.

Lookup for JSON there, you'll find almost 13 results. Check the dates of the latest revisions, the user rating, the project activity status.

UPDATE: I've just found a similar question n StackOverflow. Apparently, they are quite happy with the erlang-json-eep-parser parser.

查看更多
疯言疯语
6楼-- · 2020-01-31 03:46

I prefer Jiffy. It works with binary and is realy fast.

1> jiffy:decode(<<"{\"Name\":\"Tom\",\"Age\":10}">>).
{[{<<"Name">>,<<"Tom">>},{<<"Age">>,10}]}

Can encode as well:

2> jiffy:encode({[{<<"Name">>,<<"Tom">>},{<<"Age">>,10}]}).
<<"{\"Name\":\"Tom\",\"Age\":10}">>
查看更多
唯我独甜
7楼-- · 2020-01-31 03:52

I use the json library provided by yaws.

Edit: I actually switched over to Jiffy, see Konstantin's answer.

查看更多
登录 后发表回答