Repository navigation
Jackson 3.0.0 default for MapperFeature.DEFAULT_VIEW_INCLUSION
#75
Replies: 8 comments 16 replies
|
I voted to change it to |
|
Although number of votes is (regrettably) low, results are clear so I will call this: Decision == change the default. |
|
I will re-open this: I have concerns about performance impact, and this is why change has not been merged (there is PR). Will do some research via |
|
hi @cowtowncoder, maybe this change is a good opportunity to give guidelines/documentation around views ? It feels to me that people hav different expectations about them, and I think that's why it was/is difficult to chose a default value for DEFAULT_VIEW_INCLUSION ? |
Security concern indeed, but it is also commonly used to prevent too big workloads being serialized by allowing contextual serialization profiles, so IMO the main reason for the switch is a much better and predictable DevXP for developers to only include what has been explicitly annotated for the use case I described in https://spring.io/blog/2014/12/02/latest-jackson-integration-improvements-in-spring#json-views. |
|
Hi, I think it's already possible in many case to annotate a class to make a behavior independant of the objectmapper configuration, so this would make it more homogeneous? Also in this case, contrary to cases where the behavior configured at the objectmapper level leads to multiple useful bevahiors (like global date formats or global null inclusion), this one has one behavior that makes the class effectively useless (any view => always empty), so there is an even stronger reason to allow defining this at the class level ? |
|
Regarding the security aspects of this, it feels like if security is truely important, it should not be a configuration of the object mapper (data can change at runtime), it should be a method of the objectmapper (static enforcement): mapper.writerWithSecureView (need to find an actual good name here) (In springboot, this would probably map to an annotation on the controller) |
|
Hi, To alleviate this difficulty a possibility that seems achievable with the restriction of a an implementation that can map this behavior to constructed cached serializers, would be to have classes with 0 JsonView annotations be considered unfiltered, all fields always included (like in DEFAULT_VIEW_INCLUSION=true) It could either be the new behaviorr of DEFAULT_VIEW_INCLUSION, or if backwards compatibility or the previous behavior is important, maybe a new mapper configuration DEFAULT_VIEW_SCOPE with values ANNOTATED_ONLY and ALL saying whether the DEFAULT_VIEW_INCLUSION config applies to fields in classes with at last one defined JsonView annotation or to all fields in any class ? A downside of this approach is the increase in complexity: adding the first annotation on a field in a class changes the behavior for other fields in this class. But maybe it's worth it to make DEFAULT_VIEW_INCLUSION more usefull with big hiearchies ? |

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
(part of #72 uber-Discussion)
As of Jackson 2.x,
MapperFeature.DEFAULT_VIEW_INCLUSIONdefaults totruefor backwards-compatibility. This means that by default, properties not annotated with any@JsonVieware INCLUDED.A suggestion has been made:
FasterXML/jackson-databind#1484
to change it to
falseinstead, so only explicitly annotated properties are included.We cannot make the change in Jackson 2.x, but could change it for 3.0.0.
So let's see if there is consensus on whether to make proposed change.
Note on Framework defaults
false(i.e. different from Jackson 2.x defaults)7 votes ·
All reactions