Languages
[Edit]
EN

Jackson - prevent field serialization with @JsonIgnore

6 points
Created by:
illona
526

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).

Alternative titles

  1. Jackson - ignore field on serialization with @JsonIgnore
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

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