dimanche 7 juillet 2019

REST API to search JSON files

Suppose I've got many JSON files to generate a static web site from them. The static web sites consists of HTML files generated from the JSONs and a web server that routes HTTP GET requests to the HTMLs.

Now I'd like to implement a REST API for this site. The API should return a JSON by an HTTP GET request. For example, suppose I've got JSONs like that:

{"a1" : "111", "b1: "111", "c1" : "111"}
{"a2" : "222", "b2: "222", "c2" : "222"}
...

I need to return the 1st JSON on query a1=111 and the 2nd JSON on query a2=222.

In order to implement this API I'd like to generate an index from the JSON files at the "build time" and then query the index on the server-side to find the JSON.

Does it make sense ? How would you suggest implement it ?




Aucun commentaire:

Enregistrer un commentaire