I have some jersey resource methods set with @JsonView annotation in order to filter the fields returned in the response. I'd like to be able in some cases to override the JsonView set in the annotation with another one or sometimes completely disable it. (some queryParam would be used to define which view should set for rendering or if it should be disabled). Any ideas?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
You can customize the Jackson object writer inside a jersey filter based on the resource method annotation using the Jackson 2.3 ObjectWriterModifier/ObjectReaderModifier feature.
Refer to the Jersey documentation how to define filters and interceptors. This question may be helpful for Jersey 1.x.
Here is an example which register an ObjectWriterModifier thread local instance that changes the view class for the JAX-RS Jackson provider. I have not test the code against a JAX-RS implementation, but I believe it should work (let me know if it doesn't).