2

I have tried converting proto to java pojo . But got the error

[Stderr] Order.proto:12:18: Expected "required", "optional", or "repeated". [Stderr] Order.proto:12:21: Expected field name.

optional int32 orderID = 1; 
optional int32 quantity = 2;    
map<string,string> map_field = 4;
repeated string product = 3;

Please help me what needs to be changed. i searched on google protobuf developer site https://developers.google.com/protocol-buffers/docs/proto#maps It says that Map fields cannot be repeated, optional, or required

Please help me to resolve the issue.

gaurav
  • 2,886
  • 6
  • 24
  • 26

1 Answers1

5

Maps are a new feature in protobuf 3.0 (aka "proto3"), which is still in alpha. You are probably using 2.x, in which case there are no maps. Your best bet is to use a repeated field:

repeated MyMap map_field = 4;
message MyMap {
  optional string key = 1;
  optional string value = 2;
}
Kenton Varda
  • 41,353
  • 8
  • 121
  • 105