halaxa/json-machine ? reverse-engineered prompt
Reverse engineered prompt
Build me a small PHP library for reading huge JSON files without loading everything into memory.
I want to be able to point it at a file or any stream, then loop through the data with a normal foreach and get one item at a time. It should work for both JSON objects and arrays, and let me read just a part of the document if I give it a JSON Pointer path, like a nested section or even a single value. It should also handle JSON coming from an API response stream, not just local files.
Please make it easy to use, memory efficient, and fast, with a simple default setup. If it helps, support returning either objects or arrays, and include a way to handle bad JSON items cleanly. Add a few example scripts and tests so I can see how to use it right away. If you need to look up current PHP docs or best practices, feel free to do that.
Are you gonna build this?
make sure you review the code using coderabbit