-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
FasterXML/jackson-databind#1296 @JsonIncludeProperties #2771
Conversation
Serialization
This PR is not for being merged as-is, it's just to get early input |
Deserialization work
…into deserialization_work
Removing the [WIP] as this is now ready |
src/main/java/com/fasterxml/jackson/databind/deser/BasicDeserializerFactory.java
Outdated
Show resolved
Hide resolved
src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerBase.java
Show resolved
Hide resolved
src/main/java/com/fasterxml/jackson/databind/deser/std/MapDeserializer.java
Show resolved
Hide resolved
src/main/java/com/fasterxml/jackson/databind/introspect/JacksonAnnotationIntrospector.java
Show resolved
Hide resolved
Ok this looks pretty good, all around; only missing piece I noticed was that So: I wonder if there is need to indicate "just include all" case; at first I assumed so (from annotations), but I guess that is simply equivalent to leaving out annotation altogether. I also mentioned possibility of adding Another possible change could be to pass I'll think about these things a bit more, but so far I think this looks pretty good! |
Ok, so: In case of multiple introspectors all of them are arranged in logical chain, pair-wise, with precedence. For most annotations, primary introspectors is called to see if it finds an answer (for, say, property name via So, distinction between "not found" and "found empty" is often significant; and I think it may be important here too because not having annotation essentially means no-inclusion restrictions. But I think it looks like it depends on whether choice of both introspectors providing answer should be:
Does this make more sense? |
/** | ||
* @since 2.12 | ||
*/ | ||
public abstract BeanDeserializerBase withIgnorableProperties(Set<String> ignorableProps, Set<String> includableProps); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(note to self, mostly)
Makes sense to use different name, I think, withPropertyInclusions()
(to indicate both ignoral and/or inclusion contained), for the new method.
Set<String> prev = contextual._includableProps; | ||
if (prev != null && included != null) { | ||
Set<String> newIncluded = new HashSet<>(); | ||
// Make the intersection with the previously included properties. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not 100% sure if this is the right default: seems like there would be 3 possibilities:
- Intersection (must be in class defaults/annotations AND property)
- Union (add anything property defines)
- Overwrite/replace (use whatever property defines)
Now, adding "mode" or something in JsonIncludeProperties
(and .Value
) would allow specifying these modes easily if we want to. But even without adding that, I wonder what the most likely expected use case would be?
My guess would have been either (3) or (2).
As per my note on annotations PR (FasterXML/jackson-annotations#174), I am ready to merge the PRs and get this in for 2.12! Excited to add the feature, given its popularity. |
Merged, changed in places. But now need to figure out why there is one fail for Guava Multimaps wrt ignoral -- probably something to do with this change (maybe something about constructor changes) |
After looking at the issue, not a problem with this PR but changes I made afterwards. :) |
Ok glad to hear it, I saw your message in #1296 but could not answer. If you need that I do some follow up on the PR, I can have a look as well. |
@sp4ce thanks! I think we are good, I found the specific problem with changes I made (to add |
Fix for #1296 (
@JsonIncludeProperties
)Serialization