I've been looking for example Gson streaming API code, and I see a lot of this style:
reader.beginObject();
while (reader.hasNext()) {
switch(reader.peek()) {
case NAME:
...
case BEGIN_ARRAY:
...
case END_ARRAY:
...
}
reader.endObject();
reader.close();
That code works great when the JSON has only one "top-level" object. The hasNext() loop terminates at the end of that first object. What I need is a loop around that to process ALL the objects. Here's an abbreviated example of my JSON:
{
"meta": {
"disclaimer": "Loren Ipsum",
"terms": "https://myURL/terms/",
"license": "https://myURL/license/",
"last_updated": "2023-03-10",
"totals": {
"skip": 0,
"limit": 12000,
"total": 362818
}
},
"results": [
{"result": "value1"},
{"result": "value2"},
{"result": "value3"},
]
}
This code processes the "meta" object just fine, and never get to the "results" array.
Searched high and low.
and return when I hit the END_ARRAY. In this case, I'm looking for the "results" array - but I never get there.
– NoazDad Mar 17 '23 at 21:12