I have a json file with array of objects, i want to read it and create rest api with couple GET methods. What are best practices to do so? Should i create in memory database (H2), save json objects there and then do the rest? I am looking for most efficient solution.
2 Answers
If you JSON file is small and does not change frequently, you do not need to put it in H2 or another database. Just read the JSON file from the disk once and use it in your REST API endpoints.
Jackson is a good library for processing JSON data in Spring Boot. It offers multiple options to read and consume the JSON data.
2 Comments
someone_smarter
Thank you for answer, ill follow your advice. I saw someone using H2 database for same thing but with xlsx file. Do you mind explaining when it is a good idea to use database?
attacomsian
Here is a good read: softwareengineering.stackexchange.com/questions/190482