2

I am new to Spring-MVC.

I am sending data to my view as JSON, and there I am deserializing it to a string, but I want to pass only selected fields, I don't want all fields to send there but how to ignore selected fields I don't know.

My class POJO code :

public class account{

    private Integer userId;
    private String userName;
    private String emailId;

    //getter - setter

}

In some activity I don't want some fields so I want to avoid that fields so any idea on this confusing situation ?

kaya3
  • 47,440
  • 4
  • 68
  • 97
  • You're looking for the ```@JsonIgnore``` annotation. Google search will help you tremendously on your long and perilous journey through the valley of Spring. – Misha Jun 06 '14 at 05:25

1 Answers1

1

Add the annotation @JsonIgnoreProperties("fieldname") to your POJO. or you can use @JsonIgnore also before field name that you want to ignore while deserializing JSON.

example :

@JsonIgnore
@JsonProperty(value = "user_password")
public java.lang.String getUserPassword()
{
    return userPassword;
}

Here Is my Answer for Similar Question.

Community
  • 1
  • 1
user3145373 ツ
  • 7,858
  • 6
  • 43
  • 62