regex as protobuf message field name?

296 views Asked by At

can we define regular expression in protobuf field name? I send the request as list of dictinary in client.py file

"cur_cur_bin" : [{"cur_cur_bin1_bin3_bin1" : 4,"cur_cur_bin3_bin5_bin8" : 6} ]

I defined .proto file like,

    int32 cur_cur_bin1_bin3_bin1 = 1;
}
message Message{
    repeated cur_cur_BIN cur_cur_bin = 1;
}```

any one can explain how to define this type of field in .proto file dynamically. because 
(bin1) having some range like (1 - [1-8]) same for (bin3) like (3 -[8-11]) like this.  
1

There are 1 answers

0
jpa On BEST ANSWER

No, as far as I know there is no mechanism to generate field names automatically or dynamically in protoc.

You can create messages dynamically through the python-protobuf reflection API, but that probably doesn't make sense for your usecase.

Instead define a reasonable .proto format, and then write some custom Python code to convert your JSON data to that.