[erlang-questions] Erlang APIs and JSON

Loïc Hoguin <>
Fri Aug 30 23:57:04 CEST 2013


Hi Mark, long time no see!

On 08/30/2013 10:41 PM, Garrett Smith wrote:
> Hi Mark,
>
> On Fri, Aug 30, 2013 at 3:22 PM, Mark Allen <> wrote:
>> I am wondering if anyone has opinions on how to deserialize JSON HTTP request bodies into Erlang terms.  Tuple wrapped proplists seems to be how it comes back from mochijson2:decode() and jiffy:decode().  Erlson returns orddicts hidden in a record-like syntax via a parse-transform.
>
> It's initially odd, but {Proplist} has emerged as a standard-ish
> representation of a JSON associative array in Erlang. It's better IMO
> than dealing with the "what is this list - a string or an array?"
> question.

The question doesn't come up in jsx because it doesn't use strings. So 
you got Proplist instead of {Proplist} and <<"string">> instead of 
"string". The JSON is still checked to be valid utf-8 even if it gives 
you binaries at the end so no functionality is lost.

I don't think one is more used than the other though.

-- 
Loïc Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


More information about the erlang-questions mailing list