Assume there are multiple REST APIs that my application wants to access data from. Each API supports JSON responses but differ in the fields used to describe the data. So one API may use time whereas another one may use timestamp as key for the timestamp data. Similarly other fields like location may be represented differently.
One way for me to ingest such heterogeneous data is to write a wrapper for each of the APIs. I, however, want a more generic approach.
My application wants to retrieve (say) the following fields from each API's JSON response:
- timestamp
- latitude
- longitude
I was thinking of writing a single JSON parser but specifying a configuration file which tells the parser which field stands for what. So it would look something like:
For API1 (say)
- timestamp = 'time'
- latitude = 'location'[0]
- longitude = 'location'[1]
For API2 (say)
- timestamp = 'timestamp'
- latitude = 'lat'
- longitude = 'lng'
I am sure there would be existing methods which let you specify such data description, but I have not been able to find one. Could someone point me in the right direction?
EDIT: Please also let me know if there is a generic way of not just parsing but also creating queries for such REST APIs. For example, some APIs accept time interval as query parameter. These query parameters are also different from API to API. So please suggest how to write a generic query module that accepts a config file which tells the module how to form the queries.