<table cellspacing="0" cellpadding="0" border="0"><tr><td valign="top"><p dir=ltr>the empty object is deserialized to '[{}]'. the proplists module considers this a valid proplist with zero keys<br>
</p>
</td></tr></table> <div id="_origMsg_">
<div>
<br />
<div>
<div style="font-size:0.9em">
<hr size="1">
<b>
<span style="font-weight:bold">From:</span>
</b>
Bob Ippolito <bob@redivi.com>; <br>
<b>
<span style="font-weight:bold">To:</span>
</b>
Loïc Hoguin <essen@ninenines.eu>; <br>
<b>
<span style="font-weight:bold">Cc:</span>
</b>
Mark Allen <mallen@alertlogic.com>; erlang-questions@erlang.org <erlang-questions@erlang.org>; <br>
<b>
<span style="font-weight:bold">Subject:</span>
</b>
Re: [erlang-questions] Erlang APIs and JSON <br>
<b>
<span style="font-weight:bold">Sent:</span>
</b>
Fri, Aug 30, 2013 10:06:57 PM <br>
</div>
<br>
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td valign="top"><div dir="ltr">On Fri, Aug 30, 2013 at 2:57 PM, Loïc Hoguin <span dir="ltr"><<a rel="nofollow" ymailto="mailto:essen@ninenines.eu" target="_blank" href="javascript:return">essen@ninenines.eu</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi Mark, long time no see!<div class="im"><br>
<br>
On 08/30/2013 10:41 PM, Garrett Smith wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Mark,<br>
<br>
On Fri, Aug 30, 2013 at 3:22 PM, Mark Allen <<a rel="nofollow" ymailto="mailto:mallen@alertlogic.com" target="_blank" href="javascript:return">mallen@alertlogic.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
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.<br>
</blockquote>
<br>
It's initially odd, but {Proplist} has emerged as a standard-ish<br>
representation of a JSON associative array in Erlang. It's better IMO<br>
than dealing with the "what is this list - a string or an array?"<br>
question.<br>
</blockquote>
<br></div>
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.<br>
<br>
I don't think one is more used than the other though.</blockquote><div><br></div><div>How are 0-length arrays distinguished from 0-length proplists? This is why mochijson2 wraps proplists as {struct,P}. It also uses binaries for strings, and validates the UTF8.</div>
<div><br></div><div>-bob</div><div><br></div></div></div></div></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>