I have a folder of JSON files that I would like to use to create a simple API.
Here is a simplified version of my folder structure:
/clients.json
/clients/1/client.json
/clients/2/client.json
...
my /clients.json
file looks like this:
[ { "id": 1, "name": "Jon Parker" }, { "id": 2, "name": "Gareth Edwards" }, ... ]
and my /clients/1/client.json
file looks like this:
[ { "date": "2014-09-12", "score": 40, ... }, { "date": "2015-02-27", "score": 75, ... }, { "date": "2015-05-10", "score": 75, ... }, { "date": "2016-08-27", "score": 60, ... } ]
The identifier from clients.json
refers to the folder that contains the related data.
I have many JSON files in the clients folder, and instead of loading them individually on the client side, I wanted to create an API using Node.js, which gives me more flexibility, that is ..
returns a list of client names and /clients
identifiers
returns client data /clients/:id/details
and most importantly, the return of all customers with names and related details /clients/all/details
I started playing with json-server , however this requires your JSON to be an object, not an array, and I am stuck with the format of this JSON, unfortunately.
Appreciate any help!