Questions tagged [protocol-buffers-3]
27 questions
220
votes
9 answers
How to define an optional field in protobuf 3
I need to specify a message with an optional field in protobuf (proto3 syntax). In terms of proto 2 syntax, the message I want to express is something like:
message Foo {
required int32 bar = 1;
optional int32 baz = 2;
}
From my…

MaxP
- 2,664
- 2
- 15
- 16
74
votes
2 answers
Inheritance in protocol buffers
How to handle inheritance in Google Protocol Buffers 3.0?
Java equivalent code:
public class Bar {
String name;
}
public class Foo extends Bar {
String id;
}
What would be Proto equivalent code?
message Bar {
string name =…

Vivek Sinha
- 1,591
- 3
- 15
- 23
41
votes
2 answers
Protobuf3: How to describe map of repeated string?
The Official documentation about map type says:
map map_field = N;
...where the key_type can be any integral or string type (so, any
scalar type except for floating point types and bytes). The value_type
can be any…

lz96
- 2,816
- 2
- 28
- 46
5
votes
0 answers
Is there a way to make generated enum implement a custom interface in Protobuf v3?
I would like to have the generated enum in Proto3 implement a custom pre-existing interface, as follows:
public enum GeneratedProtoEnum
implements CustomInterface, com.google.protobuf.ProtocolMessageEnum {
// ...
}
(by default, enum…

Dmitry Kuzmin
- 73
- 4
5
votes
3 answers
compile protocol buffers 3 timestamp type in c# visual studio?
Visual Studio 2015
C#
NuGet Packages :
Google.Protobuf v3.0.0
Google.Protobuf.Tools v3.0.0
MessageType Quake
syntax = "proto3";
import "google/protobuf/timestamp.proto";
message Quake {
google.protobuf.Timestamp _timestamp = 1;
double…

BaltoStar
- 8,165
- 17
- 59
- 91
4
votes
1 answer
Protobuf Java - Case insensitive map?
I have a map that contains a user entered remote machine name, and a user entered name on the host for a program running there. Don't want duplicate entries because the user typed upper case once then entered the same name in lowercase later. …

Evan
- 2,441
- 23
- 36
3
votes
2 answers
How to Mask certain fields in Protobuf
I couldnt find a way to mask certain fields in protobuf structure. I did read about the FieldMaskUtil and tried few examples but it seems to do the reverse i.e copy fields which are mentioned in FieldMask which is different from what i wanted.…

Harry
- 528
- 1
- 5
- 21
3
votes
2 answers
Protobuf3: Serialize a Python object to JSON
According to the manual, Protobuf 3.0.0 supports JSON serialization:
A well-defined encoding in JSON as an alternative to binary proto encoding.
What have I tried
json.dumps(instance) which raised TypeError(repr(o) + " is not JSON…

Adam Matan
- 128,757
- 147
- 397
- 562
2
votes
2 answers
protocol buffers, What is in serialized data?
I am new to protocol buffers, and really want to know more about it, so sorry for noob question.
What is in serialized data, only values or both keys and values? I think there is only values, and if someone wants to deserialize it, he/she must has…

Nika Kurashvili
- 6,006
- 8
- 57
- 123
2
votes
1 answer
Constructing a cs file from a proto file?
This may seem really basic but I'm really new to C# so the google reference docs aren't that clear to me.
They instruct:
protoc --proto_path=bar --csharp_out=src --csharp_opt=base_namespace=Example player.proto
and their example is
protoc…

Matthew
- 41
- 4
1
vote
0 answers
How can print protobuf message with custom format in python?
Here my code
# protobuf message
# message Health {
# bytes mac_addr = 1;
# uint32 device_uptime = 2;
# uint32 teapot_uptime = 3;
# uint32 start_count = 4;
# uint32 start_reason = 5;
# uint32 cpu_usage = 6;
# uint32…

Abdurrahman Uslu
- 31
- 1
1
vote
1 answer
Port existing control protocol to proto3?
I am trying to port an existing control protocol definition to Google Protocol Buffers (proto3) toward the goal of generating decoding (not encoding) tools and libraries that produce human-readable strings. This control protocol has numerous one and…

iwolf
- 31
- 1
1
vote
1 answer
.Net WebAPI returning Protocol Buffer: Protocol message contained a tag with an invalid wire type
I have a *.proto file that defines two messages: MyRequest and MyResponse. This is defined in a common .NET Standard 2.0 library and uses the following NuGet packages:
…

DrGriff
- 4,394
- 9
- 43
- 92
1
vote
0 answers
Generating gRPC files for Flutter and Golang using Make file
Is this the right Make file code if I want to deploy my Golang server on Amazon AWS EC2 with this configuration:
Im not allowed to embed image so click here to see the image
Here is the Make File Code:
Shipping package
Assumes user is on MacOS, if…

Rhonda
- 11
- 2
1
vote
3 answers
protoc custom plugin erroring out with Program not found or is not executable
I am trying to build a custom protoc plugin to generate custom output from .proto files. I literally copied java file containing CodeGenerator from protoc custom plugin as a starting point and renamed it. I also followed executable and created .sh…

User
- 1,186
- 4
- 22
- 36