[erlang-questions] erljson - a fast JSON parser in Erlang

Bob Ippolito <>
Tue Jul 29 01:56:42 CEST 2008


2008/7/28 Paulo Sérgio Almeida <>:
> - strings are decoded to existing atoms, or binaries otherwise;

This doesn't really seem like a great idea for the cases where your
code expects a binary but gets an atom instead because some other part
of the system happened to have an atom of that name. It "forces" all
of your code to use atoms everywhere that you expect to match on
something...

> - fast encoding to io_lists; special care is taken to see if no escaping is
> needed, so as to reuse binaries in the structure to encode. (A sample
> testing on a small example mostly with objects gave about 4 times faster
> encoding than mochijson2; decoding was about the same speed).

Can you provide such an example benchmark? It would be pretty easy to
go add a similar special case to mochijson2's encoder.

> - encoding is liberal on allowed keys of objects; it can take integers,
> floats, atoms, lists, binaries; but produces valid json with keys being
> strings;
>  - this is an example that means the current version may not produce a
> roundtrip erlang->json->erlang, as object keys are only decoded to atoms or
> binaries; this could possibly change; some thought and polishing needed.

I'm pretty sure this is the right thing to do, at least I've found it
very convenient and that's how JavaScript behaves.

-bob


More information about the erlang-questions mailing list