-
Notifications
You must be signed in to change notification settings - Fork 46
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
set JsonInclude annotation on proto fields that are wrapped in POJO #85
Comments
still did not find a solution for this. Would greatly appreciate help with this issue. Thank you |
i noticed the line below in MessageSerializer serialize method:
to set JsonInclude.Include.NON_DEFAULT just on protobuf classes i will have to override and change both class ProtobufModule and class MessageSerializer. This is a bad solution, because we will not get future changes made to these classes in jackson-datatype-protobuf There must be a better solution. Your help is much appreciated! |
Hi,
thanks for this very useful library :)
As stated in the official protobuf java guide : "If you want to add richer behavior to a generated class, the best way to do this is to wrap the generated protocol buffer class in an application-specific class"
So i have a MyPojo which has a protobuf field named AccountInfo, see example below:
I would like to exclude the default values in protobuf AccountInfo, but to include the default values of all other members in MyPojo, like "size" member for example.
When building jackson ObjectMapper as in snippet below, all default members are excluded. For example if "size" member is zero (default Integer value) it is not included in the serialized json.
So, when sereliazing MyPojo, how do i exclude the default members of all proto members (like accountInfo) but include the default values of other non-proto members (like size)?
In other words, how can i remove the JsonInclude settings from the ObjectMapper and configure it only for the ProtobufModule?
The text was updated successfully, but these errors were encountered: