0

I have a large sized JSON string of about 1 GB for example a JSON like

$someJSON = '[{"name":"Jonathan Suh","gender":"male"},{"name":"William 
Philbin","gender":"male"},{"name":"Allison McKinnery","gender":"female"}]';

I don't want to use json_decode to convert it to a PHP array as the JSON array is about 1 GB in size and it decoding fails with 500 error Is it possible to break the JSON into smaller portions

$string1 = {"name":"Jonathan Suh","gender":"male"}
$string2 = {"name":"William Philbin","gender":"male"}
$string3 = {"name":"Allison McKinnery","gender":"female"}

and then convert it to an Array using json_decode for each variable of $string1, $string2 etc?

I cannot Split the array also as it will take more time. Maybe something like scanning the JSON, storing to an array and then discarding the array using unset() line by line so that the memory will be freed after processing the array

James Z
  • 12,209
  • 10
  • 24
  • 44
TGS
  • 19
  • 2
  • 2
    Possible duplicate of [Processing large JSON files in PHP](https://stackoverflow.com/questions/4049428/processing-large-json-files-in-php) – marekful Jan 27 '18 at 03:56
  • what will you end up doing with the data? –  Jan 27 '18 at 04:36
  • hi, I jusst need to calculate or total some fields and discard the array. – TGS Jan 27 '18 at 07:22

0 Answers0