Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Erlang JSON libraries: serialization performance?

Tags:

json

erlang

There are a number of JSON libraries available for Erlang, and it's not clear to me which have the best performance characteristics (and, secondarily, ease of use), especially for erlang-to-json serialization.

My use case requires both JSON parsing and serialization, but the Erlang code will probably be producing at least two orders of magnitude more JSON output (i.e. serialization) than it will receive input.

For reference, the libraries I know of include the following (and there may be others I haven't found):

  • mochijson
  • mochijson2
  • erlang-rfc4627
  • eep0018
like image 289
Greg Campbell Avatar asked Oct 30 '09 20:10

Greg Campbell


3 Answers

I use rfc4627.erl (I stumbled upon it, and performance has not been an issue)

However, I do expect the different native erlang libraries to perform similarly well. They share ideas (as witnessed in the code comments). AFAIK mochijson and rfc4627 share the same source erlang format.

eep018 is C, and as it is striving to implement ... hrm ... eep-0018, the term_to_json native encoder that might be included in a future version of Erlang. Never tried it and doesn't seem actively maintained.

My final recommendation is go with mochiweb's mochijson(2). It is the de facto standard and actively maintained, used by, among others, CouchDB and Facebook.

As for choosing between mochijson and mochijson2, this might help you.

like image 120
Eric Avatar answered Oct 08 '22 15:10

Eric


I've been using jsonerl lately. It's based on mochijson2 and is much more easy and intuitive to use.

like image 45
abecciu Avatar answered Oct 08 '22 17:10

abecciu


Try https://github.com/si14/erl_json_test erlang json benchmarks. It included benchmarks for:

  • List item

  • JSONX

  • Jiffy

  • Mochijson2

  • JSX

like image 2
0xAX Avatar answered Oct 08 '22 15:10

0xAX