java - How to use Jackson to conditionally serialise the fields of a POJO -


i have java class

    public class categoryitem implements serializable {     private long id;                  private string name;                 private manager manager; } 

in 1 case,i need convert fields json. on other case,i need 'id'and 'name' how can do?

give me tips.thanks

annotate pojo id , name attributes @jsonproperty , manager @jsonignore

when want id , name, use default objectmapper. when want fields, use custom objectmapper per question/answer.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -