- Your job is to create a web application that allows a user to search a provided translation file for a specific label. The search query will be the key of the label, in dot-notation. The requirements are as follows:
- When your application initializes, it must load and process a single JSON translation file named [url removed, login to view] (an example has been provided) and store the data in memory.
- I will run your application using a different JSON file, but you can assume the JSON file will be valid. The value of a JSON object can only be a string (the label), or another JSON object (a nested JSON object). There will be no arrays in the JSON object.
- The front-end of the application will be a single web page with a search interface using backbone js. The search interface will contain a search box, for entering the key, and a search results area to display the matching label. For example, if someone searched for “[url removed, login to view]”, the search page should display: “User Name”. One only search result is possible since each key is unique. If the user enters an invalid key, or a key that could not be exactly matched from the JSON file, no search results should be returned.
- The application must be written using Java and Spring Boot.
- Make the search request using AJAX. Dynamically display the search results on the screen when the response is returned. A “reverse” search option: Allow the user to search by the label, and return all of the keys to which the label belongs. This search result can return multiple keys. Once again, only exact matches need to be considered. How the UI switches between the regular search and the reverse search is up to you.
- Loading the JSON file in a usable format can be made easy by using the ObjectMapper class. This class is an included dependency with any Spring Boot web application and can convert the raw JSON file into a Map which can be further processed to generate a set of keys and values.
example for loading json file:
Objectmapper jsonMapper = new ObjectMapper();
Map<String, Object> map = [url removed, login to view](new File("[url removed, login to view]"), [url removed, login to view]);
In the map above, the value can be a String or another Map (in the case of a nested JSON object).