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
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:
public class MyPojo {
@JsonProperty("tenant_id")
String tenantId;
@JsonProperty("size")
Integer size;
@JsonProperty("account_info")
private com.examples.protobuf.AccountInfo accountInfo;
}
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:
assafcoh
changed the title
Support JsonInclude.Include.NON_DEFAULT for inner fields
Support JsonInclude.Include.NON_DEFAULT specifically on ProtobufModule
Oct 16, 2021
still did not find a solution for this. Would greatly appreciate help with this issue. Thank you
assafcoh
changed the title
Support JsonInclude.Include.NON_DEFAULT specifically on ProtobufModule
set JsonInclude annotation on proto that is wrapped in POJO
Oct 21, 2021
assafcoh
changed the title
set JsonInclude annotation on proto that is wrapped in POJO
set JsonInclude annotation on proto fields that are wrapped in POJO
Oct 24, 2021
i noticed the line below in MessageSerializer serialize method:
Include include = serializerProvider.getConfig().getDefaultPropertyInclusion().getValueInclusion();
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: