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