Вопрос

I have s simple Java bean class without any annotations or configuration that is being serialized to JSON by Spring RESTful MVC (also without any configuration, just the defaults that come with Spring Boot).

Everything works fine, except that I have a few public convenience getters that calculate some derived properties that I don't want to have included in the JSON.

What is the best way to suppress a single property from JSON serialization?

Это было полезно?

Решение

It depends on which parser your application is using under the hood. Most probably it's Jackson and adding @JsonIgnore annotation to the attribute should work.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top