[erlang-questions] fast JSON parser in C

Jonathan Gray <>
Thu Jul 24 19:19:00 CEST 2008


Joe,

It would certainly ease our integration.  JSON is certainly becoming
ubiquitous and tighter integration with Erlang would be very useful.

One note, in my current implementation and in general, there's no real
direct mapping for JSON objects/dictionaries.  While Erlang does have dicts,
we were never able to "create" them using erl_interface/ei, though I'm sure
it's possible by dissecting the dict representation.  I use a {obj, [{},{}]}
type representation now to handle JSON objects in Erlang.  Any thoughts?

+1 on new JSON BIFs :)  Willing to help in any way I can.

Jonathan Gray

-----Original Message-----
From: 
[mailto:] On Behalf Of Joe Armstrong
Sent: Thursday, July 24, 2008 3:49 AM
To: Martin Carlson
Cc: 
Subject: Re: [erlang-questions] fast JSON parser in C

Since JSON seem to be ubiquitous is seems to me that there would be
a strong case for a couple of new BIFs,  term_to_json and json_to_term.
these would work like binary_to_term and term_to_binary the difference
being that
instead of converting to a binary containing the external term format,
we convert
to a binary containing a JSON encoded string.

I imaging that modeling this code on the existing term_to_binary and
binary_to_term
code would not be impossibly difficult (you have to make it reentrant
and not to
not hog the CPU for too long ... and so on ...)

And yes - it is pretty horrid increasing the number of BIFs but this
might just be
a useful addition.

This would ease seamless integration with a lot of external programs :-)

/Joe Armstrong

On Thu, Jul 24, 2008 at 11:02 AM, Martin Carlson
<> wrote:
> You might want to go with the ei interface rather than the erl_interface
> since it is not as clumsy to use. Further, you might want to have a look
> at the ejabberd expat driver and just replace the expat stuff with your
> json SAX events.
>
>  -Martin
>
> Chris Anderson wrote:
>> On Wed, Jul 23, 2008 at 1:49 PM, Jonathan Gray <> wrote:
>>> However when I get a big chunk (around 80-120K) directly from Erlang as
>>> binary (using term_to_binary in erlang), I'm unable to decode it using
>>> erl_interface erl_decode, though it can be decoded fine from within
Erlang.
>>
>> Good to know - CouchDB's Erlang -> JSON encoding is fast enough to not
>> need help from C. I'm just working on making the JSON -> Erlang fast
>> enough, so as long as I can get string buffers over to C in the first
>> place, it sounds like you're not having a problem moving data from C
>> back to Erlang.
>>
>> Time to buckle down and code!
>>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
_______________________________________________
erlang-questions mailing list

http://www.erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list