I released a new JSON encoding/decoding library that uses NIF C++ backend and consistently outperforms most of other implementations.
Fast Erlang NIF JSON encoder/decoder with a hand-rolled recursive-descent decoder and direct term-to-JSON encoder that produce/consume native Erlang terms in a single pass. Inspired by the glaze C++ library,
glazerhas matured into a standalone implementation with no external C++ dependencies.Features
Decoding straight to Erlang terms: maps, lists, binaries, integers (including bignums), floats, booleans, and
nullEncoding Erlang terms straight to JSON, including big integers
Incremental/streaming decoding of partial input (e.g. NDJSON over a socket) via
stream_decoder/0,1,stream_feed/2,stream_eof/1Configurable representation of JSON
nulland JSON object keys
minify/1andprettify/1helpersStandalone big-integer encode/decode helpers (
encode_bigint/1,decode_bigint/1)
(numbers in µs)
JSON files: twitter (616.7K) twitter2 (758.0K) openrtb (1.2K) esad (1.3K) small (0.1K)
decode encode decode encode decode encode decode encode decode encode
---------------------------------------------------------------------------------------------------------------------
glazejson 10097.9 3947.9 14904.2 8186.0 17.4 12.5 14.8 8.7 1.3 1.5
torque 10151.7 4358.7 12899.5 6798.9 18.3 13.2 19.9 7.1 4.5 1.7
simdjsone 10345.9 7541.2 18973.3 13482.5 25.6 27.5 19.5 18.5 1.7 4.5
jiffy 30645.2 4347.6 51053.1 9500.1 50.0 28.6 32.2 19.0 7.4 4.2
jason 21005.7 12918.1 40277.2 25064.8 56.4 26.2 33.7 22.1 6.0 3.7
thoas 21151.4 13779.6 41390.0 25625.0 57.4 29.9 35.0 26.7 7.5 3.8
euneus 20488.9 12319.9 31853.9 25111.0 40.7 32.7 25.2 19.0 7.3 3.3
json 19887.1 11679.8 30902.8 24087.7 41.5 26.9 40.1 10.6 4.8 4.1
Docs: glazer
Github: glazer