Answer the question
In order to leave comments, you need to log in
API read large JSON file?
There is a real estate agency, it gives a list of apartments in a json file. And there are 17 thousand objects. I downloaded the file, looked at the size of 60mb. And not a lot and not a little .....
And the problem is how to read it. file_get_contents doesn't work ....
I tried to install this library pcrov/jsonreader and this one bcncommerce/json-stream
Anyway, there are problems, sometimes it falls off. Hosting at the client is not the most powerful. The guys will not edit the apartment output file, for our sake, they will have to work with what they have.
Which is better, download the file to yourself and try to read it, or still try to read it in the request ......
Answer the question
In order to leave comments, you need to log in
Guys N FanatPHP Ilya
I solved my problem, so I decided to write and everyone can come in handy.
Solution: I downloaded this file to myself, then I found this library https://github.com/salsify/jsonstreamingparser
It
reads perfectly, at least I read my file instantly. file_get_contents didn't work even on my laptop...
If you download the file and "put" it locally on the server, then file_get_contents 99.9% will cope with this task...
Then, as an option:
1. We hang the wget command on cron , for example, once a day or as long as you need:
wget -P /save/to/folder/file.json http://site.ru/file.json
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question