Paging #8
Closed
mgussekloo
started this conversation in
General
Replies: 1 comment 1 reply
-
Hi @mgussekloo, glad this library can help you! JSON Parser iterates over items one by one. To process items in chunks, we can collect the items in a temporary array and process the array every time it is filled with 1000 items: $chunk = [];
foreach (new JsonParser($source) as $key => $value) {
$chunk[$key] = $value;
// process and clear the chunk every time it contains 1000 items
if (count($chunk) === 1000) {
processChunk($chunk);
$chunk = [];
}
}
// process and clear the remaining items in the chunk (the last chunk might contain less than 1000 items)
if ($chunk) {
processChunk($chunk);
$chunk = [];
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Thanks for this awesome library! I'm parsing a huge JSON with this, and I'd like to do it in chunks. Is there any way to tell this library to iterate over the "first 1000", then the "second 1000", etc.?
Any help appreciated.
Beta Was this translation helpful? Give feedback.
All reactions