How to use optional?

75 views
Skip to first unread message

ccll ddd

unread,
Dec 1, 2023, 2:34:42 AM12/1/23
to Protocol Buffers
when I use grpc in python.

```
message Response {
    bool is_admin = 1;
    repeated string names = 2;
}
```

grpc server return a False for is_admin, and null value for names;
But in client, I use json_format.MessageToDict.
if I don't use including_default_value_fields=True, the is_admin will not found in dict.
{}
If I use including_default_value_fields=True, the names is a list.But I don't need names.
{"is_admin": False, "names": []}

what can i do ?



Reply all
Reply to author
Forward
0 new messages