-
-
Notifications
You must be signed in to change notification settings - Fork 799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible bug with TokenFilter #572
Comments
If I understand this correctly, I guess it... depends. For default implementation, I think design is such that only path(s) that lead to match should be retained (or optionally, drop the parent path). I don't think that can be changed. But I would not be opposed to adding alternative that would allow keeping all structure and just dropping non-matching properties. So basically if this can be added without changing existing behavior this sounds reasonable. Above is of course assuming that existing methods of |
Thanks for the reply; I can work on a PR to add a flag for this mode |
And I think you're right, conceptually it should be pretty straight-forward. Basically if a filter doesn't return null, then you immediately write the token rather than waiting to see what happens later. |
Oh. And as to JAX-RS, I could see this possibly being something to add to "stock" Jackson JAX-RS provider too, if you'd like extra challenge? |
Hmm I'll definitely investigate that as well. I was planning to PR the 2.10 branch with these changes, does that sound ok? |
Depends on what has to change: ideally all API changes would go in next minor version (2.11), and patches only for fixes. But I sometimes allow "dark launches" for safer additions so that while not documented (nor publicized), new features are available on some versions -- mostly to allow sort of more testing. So ... I guess it depends. :) FWTW I do plan on getting 2.11 pre-releases out before end of the year (in contrast to 2.10 that took forever). So that would add some delay, but not quite as bad as with some minor versions. |
I think referenced new issue (#573) replaces this issue so closing. |
Hello, I was trying to update a library I own, jackson-jaxrs-propertyfiltering, to use a
TokenFilter
and ran into an issue that struck me as surprising and/or a bug. For some background, this library extends thejackson-jaxrs-json-provider
and let's callers filter JSON responses using query params (so if you just need theid
andname
of each object you could pass?property=id&property=name
).Previously this library would serialize the response to a
JsonNode
, apply the filtering to theJsonNode
, and then serialize the filteredJsonNode
to the HTTP response. This worked fine, but is very inefficient. I tried updating this to use aTokenFilter
to apply the filtering in a streaming fashion and things worked great except we had some test failures around empty objects. For example, given a JSON document like:If the request looks like
?property=id&property=name
then things work great and the response looks like:However, if the response filters out all the properties, such as
?property=fake
, then we end up with just the empty string:So we return an HTTP 200 with no JSON at all and the caller blows up. Before the switch to a
TokenFilter
, this would have filtered out all of the object keys but retained the JSON structure so you end up with something like:I pushed a complete example to my fork:
jhaber@3e637a8
Is there a way to achieve this sort of behavior currently? If not, would you be open to a PR that adds a new option to
FilteringGeneratorDelegate
that enables this behavior?Thanks in advance
The text was updated successfully, but these errors were encountered: