-2

I need to provide a different version of response object for the same existing URI. I am going with Accept/Content-type conneg methodologies. I am using Jackson to covert my POJO into json. please help me how should i do it with jackson.

for the object model, must i have a base class and object versions are extended class?

Deepak Kumar
  • 1
  • 1
  • 1

1 Answers1

0

Instead of having one object that would be serialized in two different ways, I'd recommend using two separate DTOs. One for each version.

The content negotiation will happen not on Jackson's side, but on the JAX-RS side with the @Produces annotation.

One method returning DTOv1 will produce application/vnd.v1+json while the other will return DTOv2 with application/vnd.v2+json.