[erlang-questions] json_to_term EEP

Bob Ippolito bob@REDACTED
Mon Jul 28 22:47:11 CEST 2008


On Mon, Jul 28, 2008 at 11:42 AM, Chris Anderson <jchris@REDACTED> wrote:
> Richard,
>
> 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">>}}
>
> or
>
> 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
> win.

I have a strong preference for B. I don't think I would use it if it
was implemented as a tuple of tuples just because it wouldn't be very
convenient.

-bob



More information about the erlang-questions mailing list