[erlang-questions] json_to_term EEP

Chris Anderson jchris@REDACTED
Mon Jul 28 20:42:04 CEST 2008


Thanks again for your work on the EEP.

I've been communicating with Damien (CouchDB lead) about the shape of
objects as returned by json_to_term(). We think that returning a list
of tuples is preferable to returning a tuple of tuples.

Starting with a JSON object like:

{"key":"value", "key2":"value2"}

the two options in Erlang are:

Tuple of tuples (A):  {{<<"key">>, <<"value">>},{<<"key2">>, <<"value2">>}}


Tuple containing a list of tuples (B):  {[{<<"key">>,
<<"value">>},{<<"key2">>, <<"value2">>}]}

We both have a preference for (B - list of tuples) because based on
current usage in CouchDB, (A - raw tuples) would have us calling
tuple_to_list() constantly when we need to interact with the data. I
don't see any big drawbacks to (B) and the ease-of-use argument is
important. Requiring less code for the most common use-cases is a big


Chris Anderson

More information about the erlang-questions mailing list