0

Say I have a default way to serialize Foo objects. How can I set a specific @Controller class to use an alternate JsonSerializer for Foo objects?

With @JsonSerialize inside Foo I can only specify one universal behavior for all serializations of it. How can I have alternate ones?

Victor Basso
  • 5,556
  • 5
  • 42
  • 60

1 Answers1

0

What about using @JsonView's?

With a help of, it is possible dynamically describe the serialization/deserialization of objects, so it is possible to choose, on a per handler method basis, which field should be (and how) serialized.

Here is a good article from Spring with example.

vtor
  • 8,989
  • 7
  • 51
  • 67
  • Unfortunately @JsonView can't be applied to a class. So I'd need to add it to every method in my controller. In fact my controller extends another, so I'll be forced to override every method from the "super" controller :/ – Victor Basso Mar 06 '15 at 20:45