Reputation: 3246
I am making a call to third party REST Web Service. It returns me huge JSON string with lots of fields but I only need few of them. I am using jackson
ObjectMapper
like this :
ObjectMapper mapper = new ObjectMapper();
myDetailDto = mapper.readValue(inputLine, new TypeReference<MyDetailDto>(){});
Is there a way I don't have to include all fields in MyDetailDto
?
Upvotes: 0
Views: 338
Reputation: 8170
Make your MyDetailDto
to have only the fields that you are interested and in the class
level, add the @annotation
to ignore unknown properties.
@JsonIgnoreProperties(ignoreUnknown = true)
public class MyDetailDto { }
Upvotes: 1