You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there any way to ignore @JsonAttribute(ignore = true) when serializing the Object?
Use-case:
A class is used for both sending the data to the server and local caching. Some fields must not be sent to a server but should be cached.
NOTE: I can do this with inheritance. "remote" and "cache" models would inherit the same class and have specific fields ignored with @JsonAttribute(ignore = true). The problem is inconsistency; e.g. any change (field addition or removal) in either of these child classes will result in indeterministic bugs
The text was updated successfully, but these errors were encountered:
The closest you can get to this would be to send only non-null fields from server and manage the value of those via custom formatter.
The thing is I'm trying to avoid customization for two exact reasons:
Bugs; Future changes in class would require more customizations and if forgotten may lead to bugs
Verbosity; Current models even have other classes as members which have more fields annotated with @JsonAttribute(ignore = true)
It seems you want some runtime policy for field behavior.
Actually, I was thinking about an option to build DslJson instance that would keep fields even if they're annotated with @JsonAttribute(ignore = true). This would eliminate the need for a runtime policy, I think. But with the current implementation, this seems unlikely because anything annotated with @JsonAttribute(ignore = true) is excluded from Converters
Is there any way to ignore
@JsonAttribute(ignore = true)
when serializing the Object?Use-case:
A class is used for both sending the data to the server and local caching. Some fields must not be sent to a server but should be cached.
NOTE: I can do this with inheritance. "remote" and "cache" models would inherit the same class and have specific fields ignored with
@JsonAttribute(ignore = true)
. The problem is inconsistency; e.g. any change (field addition or removal) in either of these child classes will result in indeterministic bugsThe text was updated successfully, but these errors were encountered: