cerbero90 / json-parser

🧩 Zero-dependencies lazy parser to read JSON of any dimension and from any source in a memory-efficient way.
MIT License
671 stars 11 forks source link

Examples for each source #4

Closed theqewk closed 6 months ago

theqewk commented 6 months ago

It would be great if there were examples for each source. Since now it is not clear, for example, how to work with Laravel request, when you receive data via the API, the request immediately produces an array and because of this an error.

cerbero90 commented 6 months ago

Hi @theqewk, can you please be more specific with your issue? An example of the code you're writing would help.

If I understood well, you are using the Laravel HTTP client to perform a request and obtain a response, e.g.:

$response = Http::get('...');

in that case, you can simply pass the response to JSON Parser:

use Cerbero\JsonParser\JsonParser;

$response = Http::get('...');

foreach (new JsonParser($response) as $key => $value) {
    // ...
}
theqewk commented 6 months ago

I realized my mistake and corrected it. This is not relevant now. Thanks for the answer.