Hi Yash,<div><br></div><div>I don't know if it meets your requirements, but I wrote a SAX-like JSON parser a couple of years ago. You can find it on <a href="http://trapexit.org">trapexit.org</a> in the user contributions section:</div>
<div><br></div><div><a href="http://forum.trapexit.org/download.php?id=158">http://forum.trapexit.org/download.php?id=158</a></div><div><br>Good luck,</div><div>Willem<br><br><div class="gmail_quote">On Fri, Jan 18, 2013 at 1:18 PM, Yash Ganthe <span dir="ltr"><<a href="mailto:yashgt@gmail.com" target="_blank">yashgt@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote">
<div lang="EN-US" vlink="purple" link="blue">
<div>
<p class="MsoNormal">SAX allows the client application to read an XML piece-by-piece. This is different than DOM which expects the entire XML to be loaded in memory. SAX is thus useful for reading very large XML documents.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Mochijson is a good JSON parser which emits structs that correspond to individual JSON strings. It however expects the entire JSON string to be given to its functions.<u></u><u></u></p>
<p class="MsoNormal">If I have about 10000 records in an JSON such as this,<u></u><u></u></p>
<p class="MsoNormal">{ "d" : <u></u><u></u></p>
<p class="MsoNormal">[<u></u><u></u></p>
<p class="MsoNormal"> {<u></u><u></u></p>
<p class="MsoNormal"> "ID": 1, "Name": "p1", "Email": "<a href="mailto:p1@p1.com" target="_blank">p1@p1.com</a>"<u></u><u></u></p>
<p class="MsoNormal"> }, <u></u><u></u></p>
<p class="MsoNormal"> {<u></u><u></u></p>
<p class="MsoNormal"> "ID": 2, "Name": "p2", "Email": "<a href="mailto:p2@p2.com" target="_blank">p2@p2.com</a>"<u></u><u></u></p>
<p class="MsoNormal"> }, <u></u><u></u></p>
<p class="MsoNormal"> {<u></u><u></u></p>
<p class="MsoNormal"> "ID": 3, "Name": "p3", "Email": "<a href="mailto:p3@p3.com" target="_blank">p3@p3.com</a>"<u></u><u></u></p>
<p class="MsoNormal"> }, <u></u><u></u></p>
<p class="MsoNormal"> {<u></u><u></u></p>
<p class="MsoNormal"> "ID": 4, "Name": "p4", "Email": "<a href="mailto:p4@p4.com" target="_blank">p4@p4.com</a>"<u></u><u></u></p>
<p class="MsoNormal"> } . . . . .<u></u><u></u></p>
<p class="MsoNormal">] }<u></u><u></u></p>
<p class="MsoNormal">the entire JSON string would have to be first obtained and then passed to mochijson/mochijson2.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I am looking for a way to let the module give me one record at a time from the large JSON-formatted array. Is there any module that lets us do this?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
<p class="MsoNormal">Yash</p></div></div></div>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>