As far as I am aware, a string is a scalar so you can't set it to null.
https://protobuf.dev/programming-guides/proto3/#scalar

So if you have a map<string, string> then both the keys and values can not 
be null.

You may be able to try using the StringValue type from the Well-Known Types:
https://protobuf.dev/reference/protobuf/google.protobuf/

using a map<string, StringValue>, and most integrations will convert the 
StringValue to a simple nullable string.

On Thursday, May 30, 2024 at 10:40:45 AM UTC-4 Shenghe Wang wrote:

> Hi,
>
> I want to set an int field to 'null' when user want to clear some choice 
> but nullpointerexception was threw. I use map<string, string> to store the 
> data which will be updated. But map do not accept null value. Is there any 
> way to store the null value into a map? 
>
> Thanks a lot
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/30ebd7a4-3f43-4d0f-9ed0-1a7a6c6503e5n%40googlegroups.com.

Reply via email to