Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top