Wednesday, May 16, 2018

Annotation - 01 __ @JsonIgnore

The Jackson annotation @JsonIgnore is used to tell Jackson to ignore a certain property (field) of a Java object. The property is ignored both when reading JSON into Java objects, and when writing Java objects into JSON. Here is an example class that uses the @JsonIgnore annotation:


import com.fasterxml.jackson.annotation.JsonIgnore;

public class PersonIgnore {

    @JsonIgnore
    public long    personId = 0;

    public String  name = null;
}



In the above class the property personId will not be read from JSON or written to JSON.


Source By - http://tutorials.jenkov.com/java-json/jackson-annotations.html#jsonignore

No comments:

Post a Comment