-
Notifications
You must be signed in to change notification settings - Fork 39
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
runtime-configuration must have precedence over annotation #169
Comments
It looks like an implementation issue. What implementation are you using? |
I am using "javax.json.bind-api-1.0" with impl:
|
Yes, thanks. Looks like an implementation issue: Moved: eclipse-ee4j/yasson#290 |
The issue eclipse-ee4j/yasson#290 was closed because according to @aguibert:
Does this makes sense? Annotations are hard coded within the class: this should be treated as "global configuration". Where the JsonbConfigs should be treated as "local configuration". Imagine a json with Actually, it is impossible to override the annotation settings by a Jsonb-Config (which can be used multiple times with different configurations in runtime code). Please consider to adapt the spec so that that runtime configuration can have precedence over (hard coded) annotations. I think, it makes sense. |
Global means shared accross attributes/classes, local is the opposite so annotations are clearly local and jsonbconfig global IMHO. In all cases, config must override what is hardcoded for flexibility reasons. |
Yep, agree with you here.
I would guess the opposite here? The JsonbConfig should supply the default configurations, but if a class/method/field specifies otherwise (e.g.
The spec says that if there is a conflict between the "config wide configuration" and some annotation, then the annotation should win, which is the way Yasson currently behaves. Is there a TCK test to clarify which way this behavior should be implemented? I don't have access to the JSON-B TCK, so I can't check. |
It is common to have to override the way a class is serialized for a partocular backend or to enable a dev option so annotations never override environment. Env is jsonbconfig for jsonb spec. In other words: enable to not recompile the app to change a setting please. |
I don't think that the global config-wide setting should be overriding fine-grained annotations. The global setting should be used to define what the default behavior should be if not otherwise specified by annotations on a particular class/field/method. This is the way the spec is currently written. Inverting the behavior so that global config-wide configuration takes precedence over annotation-specific configuration would be a big breaking change for users for no real reason. Instead, I think we should focus on these issues which will give a solution to the problem without breaking existing behavior: |
Actually, fine grained annotations are like chiseling in stone and never changable by global configurations. So there is no way to have global control over all of these annotations..If the spec really tells that what you said, then it should be changed. |
Now runtime configuration is global. @aguibert is right, it can be overridden by annotations on smaller scopes like classes, fields, etc. In the new version of the spec we are planning to introduce the runtime extended configuration where you will be able to configure everything you do now with annotations. This configuration will have preference over everything. |
Ok, thanks. Good to know that it will be possible in future. Feel free to close this issue.. |
Annotating a class with
and printing the json string with
actually prints the NULL-Values. However, it should NOT print the null values, because any runtime-configuration should have precedence over their corresponding annotations.
(Tested with jakarta.json.bind-api v1.0.1)
The text was updated successfully, but these errors were encountered: