How to choose which serialize field - Jackson

2

I'm using Jackson to convert my objects to Json . The fields I do not want to serialize markup with @JsonIgnore annotation, but in some cases I wanted to serialize those fields. Is there any way to choose when to serialize them?

    
asked by anonymous 04.04.2016 / 16:11

1 answer

2

You have two alternatives:

1 - You create classes to represent information that should be serialized for each case and populate those classes as needed.

2 - You can create a custom serializer that implements the com.fasterxml.jackson.databind.JsonSerializer interface, register that serializer in your ObjectMapper , and serialize it programmatically as needed.

    
04.04.2016 / 18:34