incubator-couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Anderson" <jch...@grabb.it>
Subject json format and optimization
Date Sun, 20 Jul 2008 16:24:47 GMT
I've somehow goaded myself into taking on the JSON/Erlang problem.
First, the format needs agreement, then implementation can begin.

On the format, Joe Armstrong said this on one of the mails that had
been forwarded to the list earlier:

>>>>>> I think that:
>>>>>>
>>>>>> lists should *only* be used for json_arrays
>>>>>> binary should *only* be used for json_strings
>>>>>> json objs should be *only* be tuples (of pairs)
>>>>>> {{Tag,Val},{Tag,Val},...}
>>>>>> (possibly {Tag1,Val1,Tag2,Val2,....} might be better???)
>>>>>>
>>>>>> I think it would be a good idea to isolate this problem - agree
>>>>>> (having done some
>>>>>> measurements, on the fastest and *prettiest* way to do this) -
>>>>>> jointly
>>>>>> change
>>>>>> your code bases (at the same time) and then tell the world -
>>>>>> then issue
>>>>>> ONE
>>>>>> library.

but he also said this:

>>>>>> @type json_object = {[json_tag::binary(), json_term()]}
>>>>>> @type json_string() = binary()

So I suppose reasonable people can disagree. :)

I'd like to see a format that translates intuitively between JSON and
Erlang literals - to that end, this one seems easiest to me:

{{<<"key">>,<<"value">>},{<<"another_key">>,[1,2,3]}}

Maybe there is an advantage to a format like this (note the "[ ... ]"):

{[{<<"key">>,<<"value">>},{<<"another_key">>,[1,2,3]}]}

 - are there pros to this approach I don't realize?


As far as implementation goes, I'm looking at the Foreign Function
Interface draft http://erlang.org/eeps/eep-0007.html which may be a
good way to get a fast, correct, and *already done* JSON library
written in C to interface with Erlang. By default it translates C
buffers to Erlang binaries, so it seems a good fit.

This C JSON library looks promising (after only a couple of minutes of
research) http://lloydforge.org/projects/yajl/ Maybe there are better
ones out there I should know about?

I don't know if the FFI is fast enough for our needs - is there a
chance a pure Erlang implementation would be faster? Any other
feedback I should have?

I think it was Jan who said:

>> I'm starting to think that the interested parties should join the same
>> list! :p

I agree, but I'm not sure which list it should be. Just joined the
Erlang list, but haven't posted there yet.


Thanks!
Chris

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

Mime
View raw message