Re: [protobuf] how to ignore some fields when serialize object in proto3

2022-11-04 Thread 'Adam Cozzette' via Protocol Buffers
No, there is no built-in support for serializing a message while ignoring
particular fields. Probably the easiest way to do that would be to just
make a copy of the message that excludes the fields you want to skip.

On Thu, Nov 3, 2022 at 8:16 PM 哈  wrote:

> just like
> protected void init(Kryo kryo) {
> kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
> Serializer serializer = kryo.getSerializer(More.class);
> if (serializer instanceof FieldSerializer) {
> FieldSerializer fieldSerializer = (FieldSerializer)serializer;
> fieldSerializer.removeField("test");
> }
> }
>
> when i serialize object, kryo will ignore 'test' filed.
> can i do this in proto3 ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to protobuf+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/protobuf/0ded41d3-6cbc-4cf3-85fb-b5f16b852e03n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/CADqAXr7QwBfBCEg9_O1ZimFn%3DLZ07-NEK2s-HCLdnn-dzQqcBQ%40mail.gmail.com.


[protobuf] how to ignore some fields when serialize object in proto3

2022-11-03 Thread
just like 
protected void init(Kryo kryo) {
kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
Serializer serializer = kryo.getSerializer(More.class);
if (serializer instanceof FieldSerializer) {
FieldSerializer fieldSerializer = (FieldSerializer)serializer;
fieldSerializer.removeField("test");
}
}

when i serialize object, kryo will ignore 'test' filed.
can i do this in proto3 ?

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/0ded41d3-6cbc-4cf3-85fb-b5f16b852e03n%40googlegroups.com.