Parse a huge JSON file
<p>I have a very large JSON file (about a gigabyte) which I want to parse. </p>

<p>I tried the JsonSlurper, but it looks like it tries to load the whole file into memory which causes out of memory exception.</p>

<p>Here is a piece of code I have:</p>

<pre><code>def parser = new JsonSlurper().setType(JsonParserType.CHARACTER_SOURCE);
def result = parser.parse(new File("equity_listing_full_201604160411.json"))

result.each{
println it.Listing.ID
}
</code></pre>

<p>And Json is something like this but much longer with more columns and rows</p>

<pre><code>[
{"Listing": {"ID":"2013056","VERSION":"20160229:053120:000","NAME":"XXXXXX","C_ID":["1927445"],}},
{"Listing": {"ID":"2013057","VERSION":"20160229:053120:000","NAME":"XXXXXX","C_ID":["1927446"],}},
{"Listing": {"ID":"2013058","VERSION":"20160229:053120:000","NAME":"XXXXXX","C_ID":["1927447"],}}
]
</code></pre>

<p>I want to be able to read it row by row. I can probably just parse each row separately, but was thinking that there might be something for parsing as you read.</p>