[erlang-questions] json_to_term EEP

Kevin A. Smith kevin@REDACTED
Mon Jul 28 21:34:21 CEST 2008


On Jul 28, 2008, at 2:42 PM, Chris Anderson 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.

Wouldn't B also allow us to access the data as a proplist? If so, that  
seems like another reason to vote for B.

--Kevin

>
>
> Chris
>
> -- 
> Chris Anderson
> http://jchris.mfdz.com
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list