Thilo
Thilo

Reputation: 262504

Can I suppress a public bean property in Spring RESTful MVC JSON serialization?

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?

Upvotes: 0

Views: 651

Answers (1)

dimoniy
dimoniy

Reputation: 5995

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.

Upvotes: 3

Related Questions