Skip to content
Advertisement

Change httpresponse with DTO

I run in container fake smtp and it has own api, but it’s not readable and i dont need like 80% of response, so how i can use DTO to make response more readable and less verbose?

JavaScript

it responses huge json, i need to implement my DTO to make it more readable and remove unnecessary parts of json

Advertisement

Answer

I know this is an old question, but…

As found as an answer for this question: Ignore missing properties during Jackson JSON deserialization in Java

You can just add @JsonIgnoreProperties(ignoreUnknown = true) to ignore every field you did not specifically asked for in your DTO.

You can then convert your json to your object jackson like so

JavaScript

where response is your HttpResponse.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement