0

I'm recently trying to build an small webapp to enable AJAX call my controller and return the JSON result. I understand the annotation

@JsonView(Views.Public.class)

serves as a filter to exclude all fields that you don't want them to be serialized. Basically, all fields that don't annotated with this JsonView will be excluded.

So my question is: in a Spring controller, is annotating JsonView necessary? What if you don't include them at all, neither in your controller nor in your model object?

Any link/article will be greatly appreciated. Thank you!

OD Street
  • 1,067
  • 3
  • 14
  • 21

1 Answers1

0

As you already noticed, JsonView is only necessary, if you want to filter some fields during the entity serialization. If you don't specify this annotation, all fields of the entity, which is returned in the controller, are serialized.

dunni
  • 43,386
  • 10
  • 104
  • 99