Explore Courses Blog Tutorials Interview Questions
0 votes
in Java by (3.4k points)

I'm using Jackson JSON library to convert some JSON objects to POJO classes on an android application. The problem is, the JSON objects might change and have new fields added while the application is published, but currently it will break even when a simple String field is added, which can safely be ignored.

Is there any way to tell Jackson to ignore newly added fields? (e.g. non-existing on the POJO objects)? A global ignore would be great.

1 Answer

0 votes
by (46k points)

You can use Jackson's annotation on the class level, check it out here.

You need to add this only at the top of your class:

@JsonIgnoreProperties(ignoreUnknown = true)

public class Foo {



You need to use different import as it depends on the version of the Jackson you are using. For the latest one, use:

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

For older versions:

import org.codehaus.jackson.annotate.JsonIgnoreProperties;

Related questions

Browse Categories