This question already has an answer here:
Hello guys I have a assignment, which I have honestly no idea how to complete. I have a huuuge Json file which is 22 GB big, so I have to get the data from it but it's full with empty spaces and new lines and I have to trimm does before even opening the file. I tried getting the data and trim it but it says it is out of memory I even set the memory limit to -1 if anyone has any idea how is that supposed to happen please I am open to suggestions.
</div>
There is simple and cool parser for parsing large JSON files.
https://github.com/salsify/jsonstreamingparser
Also maybe you will find an answer on the following links
Parse large JSON file
Processing large JSON files in PHP