Answer the question
In order to leave comments, you need to log in
How to create a dynamic JSON file?
Hello!
On many sites, I noticed that the data is selected not just by some API, but directly to a file with the json extension. For example:
example.com/movies.json
How to make such a "dynamic" json file? Or is it just a trick made with .htaccess and the return comes from, for example, a PHP file?
Answer the question
In order to leave comments, you need to log in
as a rule, this file is dynamic, but not a fact, there is no trick here, just the request goes through php and it forms a valid json in response
In principle, you can write .htaccess php for a specific JSON, as well as for CSS.
But I think it’s somehow smarter done there, the same thing in Google, I don’t even know what’s “inside” there.
It doesn't matter what the address is, and it doesn't even matter what the json headers are. There are several layers:
* Request URL - you can send any address to any file - even to static, even to an executable script
* backend - there may be a generated file, or maybe the same executable script
* response - in which the headers indicate that what type of data is being returned. The script can control it
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question