[erlang-questions] fast JSON parser in C

Chris Anderson <>
Fri Jul 25 02:50:10 CEST 2008


On Thu, Jul 24, 2008 at 6:56 PM, Bob Ippolito <> wrote:
> I'd be curious to know if leex/yecc can do any better than mochijson2
> (which is written by hand), especially considering that it uses
> binaries instead of strings.

The version of mochijson2 that is in CouchDB's trunk (not in use) is
about twice as fast as cjson - which is used by CouchDB currently.

After spending a day writing my own leex/yecc parser, it turns out to
be about 3 times slower than cjson, and about 6 times slower than
mochijson2. I could probably optimize the grammar definition to try to
make it faster. I was hoping that the magic of parser-generators would
give me a big jump on the hand-crafted code. Since it didn't, I don't
plan to pursue it any further.

If anyone wants to see the leex/yaac code, I can put it online.

-- 
Chris Anderson
http://jchris.mfdz.com



More information about the erlang-questions mailing list