Comments (4)
Hey Giovanni, this is hard to avoid with the current design. Our message body writer converts the response to a JsonNode
, filters the JsonNode
based on the requested properties, and then writes the filtered JsonNode
to the response stream.
A different approach would be to use Jackson's native PropertyFilter
; I can play around with this and see if it's feasible. My first concern is that PropertyFilter
might only work for bean properties using the standard bean serializer, whereas the current design lets you filter maps, objects with custom serializers, etc.
from jackson-jaxrs-propertyfiltering.
I played around with this for a little bit but ran into a few issues. PropertyFilter
does work for maps, but not for objects with custom serializers. Also, it seems that only one PropertyFilter
can be active for a given object, meaning that activating our PropertyFilter
would cause any existing PropertyFilter
registered for the object to not work. Finally, inside the PropertyFilter
I don't see any way to access the full path to the property name which is necessary for filtering on subfields using dot-notation (ie, if you had JSON similar to the one in the readme, when filtering the child
subobject the fields would just be called id
and name
, there would be no way for the filter to tell that it was inside of subobject called child
).
Let me know if you have any other ideas, otherwise I don't think there's much we can do to solve this use-case unfortunately
from jackson-jaxrs-propertyfiltering.
Hi @jhaber and thank for your interest in this issue. I'm sure this is doable with Jackson's PropertyFilter
including nested fields with dot-notation, since it's what Jersey's Entity Filtering does; see also [1] and [2].
It supports runtime filtering by query string parameter, filtering by security constraints and custom annotation based filters; and all before Jackson serialization, thus preventing access to lazy loaded properties.
[1] https://github.com/jersey/…/org/glassfish/jersey/message/filtering
[2] https://github.com/jersey/…/jackson/internal/JacksonFilteringFeature.java
from jackson-jaxrs-propertyfiltering.
If you need contextual serialization then you could use this: https://www.baeldung.com/jackson-json-view-annotation
from jackson-jaxrs-propertyfiltering.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jackson-jaxrs-propertyfiltering.