I have a task whereby I need to integrate with a third party API. I am planning to do something along these lines: https://spring.io/guides/gs/consuming-rest/, meaning using Spring’s RestTemplate to retrieve the response of an external API from within my Spring Boot application. Until this all good, but the second step is to "re-construct" aka convert the existing response to a new format.
For example, the original response from the 3rd party API is something like:
and the expected customised output should look like:
Expected changes are both in format/data structure (e.g. field_3_1 is now a field inside an array) and the field naming convention (e.g: "id" becomes "application_id"). Is there any Spring library/class I can use for easily make the conversion? I will create a new model class with the customised response, but I am not sure about the approach for re-structuring the data. Can you help? Is there any example I can look it up?
thank you for your reply. So, as it stands, I can successfully consume the third party service for which I created a Dto with all expected @JsonProperty per field. I have also created an entity for the expected new format and its Dto. What is the best to go about? Can I convert the initial Dto with the new format one and in my Controller I will return the new format? Would you happen to have any example I can check?