Search code examples
protocol-buffersgrpcgrpc-javagrpc-pythonprotobuf-java

how we can parse proto file if it having "." and "-" sign


I create one proto file using java and another using python when I put "." and "-" sign in proto file message field name it shows error that is "missing field number". I m not able to parse that file. and if proto file not accept this character please can share list of character which proto file not accept.


Solution

  • Please find the protobuf documentation on proper syntax for defining messages in protos.

    . is used for selecting an attribute of an object in python, so obviously one shouldn't use it in message fields of proto. Instead You can use _ as character for separating words in a single field name.

    A small Sample for you :

    syntax = "proto3";
    
    message SearchRequest {
      string query = 1;
      int32 page_number = 2;
      int32 result_per_page = 3;
    }