Jackson: Unrecognized field, not marked as ignorable (how to fix)
Codemia Knowledge Hub ·
Jackson throws UnrecognizedPropertyException ("Unrecognized field, not marked as ignorable") when the JSON contains a field that does not map to any property of the target Java class. Fix it by adding the field to the class, by telling the ObjectMapper not to fail on unknown properties, or by annotating the class with @JsonIgnoreProperties(ignoreUnknown = true).
Why Jackson rejects the field
During deserialization, Jackson matches JSON fields to properties of the Java object. Unless it is configured to ignore mismatches, any extra field causes the exception. This strict checking protects data consistency, but it gets in the way with flexible schemas or third-party APIs whose JSON you do not control.
Example that fails
Deserializing this JSON into an Employee fails, because the class has no department field:
Three ways to fix it
- Add the missing field: if
departmentmatters to your application, adding it to the class is the best solution. - Ignore unknown fields globally: if the extra fields are not needed, configure the
ObjectMapper:
- Ignore unknown fields for one class:
@JsonIgnorePropertiesignores unrecognized fields on specific classes without changing the global configuration.
Choosing between them
- Data integrity and security: if these matter most, avoid global ignore settings and handle mismatches explicitly.
- Unpredictable input: if you consume JSON from external APIs that may change, ignoring unknown properties is often more practical.
- Neither fits: for complex cases where neither ignoring nor failing is right, a custom deserializer gives full control.
In production, log these errors. They are often the first sign that an external API has changed.
| Scenario | Solution | Description |
| Required fields missing from class | Add fields | Add missing fields in the Java classes to capture all necessary information. |
| Ignoring extra fields | Configure ObjectMapper or use @JsonIgnoreProperties | Either update the ObjectMapper settings to ignore unknown properties or use annotations for specific classes. |
| Managing third-party data | Ignore unknown properties or use custom deserializers | Particularly for external APIs, consider ignoring unknown properties or write custom deserializers to handle variability gracefully. |
| Improve error feedback | Custom exception handling | Implement custom exception handling to provide detailed feedback about deserialization issues. |
Related reading
- Java-R integration?
- Java8 Why is it forbidden to define a default method for a method from java.lang.Object
- Java - Convert integer to string
- Java - escape string to prevent SQL injection
- Java - get the current class name?
- Java - How to create new Entry (key, value)
- java - illegalStateException Cannot find changelog location class path resource liquibase
- Java - JPA - Version annotation
System design interview problems on this topic
- Design an API Rate Limiter: solution and walkthrough
- Design a Distributed Messaging System: solution and walkthrough
- Design an Online Payment Service: solution and walkthrough
- Design a Key Value Store: solution and walkthrough

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseData Structures & Algorithms practice on Codemia
Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.