Skip to content
Sharp

HTTP JSON APIs · interview question

When using Jackson's ObjectMapper, which annotation ensures that unexpected fields in a JSON response do not cause deserialization errors?

Multiple choiceEasychapter-11-curatedpremiumhttp-json-apisapi-versioning
Choose one answer
Answer and explanation

Correct answer

B. @JsonIgnoreProperties(ignoreUnknown = true)

Why

The @JsonIgnoreProperties(ignoreUnknown = true) annotation tells ObjectMapper to ignore any JSON fields that do not have a corresponding property in the Java class, preventing deserialization errors.

Test yourself on HTTP JSON APIs

A free test with instant, explained results. No account needed.

Start free test
All HTTP JSON APIs questions →