Link to home
Start Free TrialLog in
Avatar of Rohit Bajaj
Rohit BajajFlag for India

asked on

Which is better sharing Data as a json or in a file

Hi,
I want to build an api that given a stock id provides the high, low, open, close values for it at the end of the day.
Now i thought of two approaches
1) Keep all the data in memory in a Map<String, Stock> where String is the stockId
2) Upload all data to an Excel file and clients can fetch that file.

Now i can use a mix of the solutions  -
A client can either want one stock value or it can want all the values.
In the first case i will use the map.
In the second case i have a choice
1) Either to return the whole map as a json
2) Provide client a url to download the file.

Although both seems similar as at the end all we are doing is sharing data.

What are the pros and cons of both the approaches.
I can think of the following :
File uploading
1) File uploading will need  a s3 bucket setup an extra thing.
2) Benefit is that we can store older copies of the file and clients can easily access older copies if they want

Json
1) No need for anything extra. Its just plain and simple return the whole json from the map.

Please confirm if above what i wrote is correct. And also any other pros and cons you see.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rohit Bajaj

ASKER

But consider the case where lot of query will be there which want all the data.
Then it will be better to have data uploaded somewhere and provide the data from there rather than querying.
This will save time.
Why don't you use a caching mechanism then like Redis/Hazelcast/Infinispan/etc?
:)