JsonInclude.Include.CUSTOM define criteria on seperate field #3740
Replies: 1 comment 1 reply
-
I can see the need for co-constraints, so at very general level it would be nice to support in some form. But I suspect this goes beyond limits of Jackson does not current provide anything out-of-the-box for constraints that span multiple properties, at least. But it is definitely possible (and maybe even likely) that some developers have built things like you describe, so maybe someone could share how they want about this? |
Beta Was this translation helpful? Give feedback.
-
I'm wondering nobody else has the feature request that the JsonInclude.Include.CUSTOM annotation not only is able to validate the current value the annotation is set on but on another field of the same class.
My use case is, that I have a boolean field "arrested" which allways should be marshalled. Then there is a field "arrestedIndex" which is an Integer field. This only should be marshalled when "arrested" is set to "TRUE" regardless what the content of "arrestedIndex" is.
With the current Include.NON_EMPTY or Include.NON_NULL I only can tell the system to marshall the field depending on these rules.
With the Include.CUSTOM annotation I could filter on other values too, but I will not be able to depend the decision whether to marshall the actual field depending on another field.
This possibility would boost up the Include.CUSTOM validation system. What do you think?
Or am I not aware of an allready existing feature, which handles this?
Beta Was this translation helpful? Give feedback.
All reactions