Languages
[Edit]
EN

Jackson - prevent field serialization with @JsonIgnore

6 points
Created by:
illona
316

In this short article, we would like to show how to ignore some fields serialization working with Jackson library.

Quick solution (use @JsonIgnore annotation):

package com.example;

import javax.persistence.Entity;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation;

@Entity
@Table(name = "users")
public class UserEntiy {

    // some fields here ...    

    @JsonIgnore
    String ignoredField;

    // some fields here ...   
}

Note: @JsonIgnore causes the field will be omitted and not serialized by Jackson (use @JsonProperty to get same effect on deserialization).

Java JSON - Jackson lib

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join