Domanda

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?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top