<div>Hi all,</div>
<div> </div>
<div>How about a SAX-like API? See for example <a href="http://www.p6r.com/articles/2008/05/22/a-sax-like-parser-for-json/">http://www.p6r.com/articles/2008/05/22/a-sax-like-parser-for-json/</a>. I can imagine that it would be easy to create any of the forms proposed in this thread based on such an API. On the other hand it would allow you to do things that you wouldn't be able to do with a parser that produces a complete representation at once (in particular: parsing very big documents), and it would be better suitedt to support a 'data mapper' approach like the Erlang ASN.1 implementation, Googles Protocol Buffers or erlsom.</div>

<div> </div>
<div>Regards,</div>
<div>Willem<br><br> </div>
<div><span class="gmail_quote">On 7/29/08, <b class="gmail_sendername">Richard A. O'Keefe</b> <<a href="mailto:ok@cs.otago.ac.nz">ok@cs.otago.ac.nz</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">On 29 Jul 2008, at 9:51 am, Paulo Sérgio Almeida wrote:<br>> I think there is no doubt that lists will be more useful than<br>
> tuples. There is, however another option, that I have been using in<br>> a json parser I wrote:<br>><br>> (C) an object is simply a proplist, i.e. a list of tuples.<br><br>This is in fact what I originally proposed,<br>
the tricky point being that {} is a legal empty object in JSON,<br>and we can't map that to [] because that's the representation<br>for the empty sequence [].<br><br>(O) Original proposal: {} => {}, other objects => list of pairs<br>
(A) Armstrong version: object => tuple of pairs, no exceptions.<br>(B) Object => {list of pairs}.<br>(C) Almeida proposal: as (O) but {} => [{}].<br><br>The arguments for usability of the result in Erlang are the<br>
arguments that originally had me proposing (O).<br><br>However, I note that nothing stops us providing a range of<br>handy-dandy functions that work on tuples of pairs.<br><br>%(O)<br>is_object({})        -> true;<br>is_object([{_,_}|_]) -> true;<br>
is_object(_)         -> false.<br><br>%(A)<br>is_object(T)         -> is_tuple(T).<br><br>%(B)<br>is_object({T})       -> is_list(T).<br><br>%(C)<br>is_object([T|_])     -> is_tuple(T);<br>is_object(_)         -> false.<br>
<br>It's rather annoying to be so bothered about empty objects;<br>do they occur in practical JSON?  Proposal (C) seems neat enough;<br>the main problem is fitting the results with @type.<br><br>--<br>If stupidity were a crime, who'd 'scape hanging?<br>
<br><br><br><br><br><br><br>_______________________________________________<br>erlang-questions mailing list<br><a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br><a href="http://www.erlang.org/mailman/listinfo/erlang-questions">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div><br>