Getting all field names from a protocol buffer?

后端 未结 3 2057
予麋鹿
予麋鹿 2021-02-02 08:22

I want to get all the field names of a proto into a list. Is there a way to do this? I looked in the documentation and there doesn\'t seem to be anything for this.

3条回答
  •  萌比男神i
    2021-02-02 09:02

    You can easily get a list of fields as follows

    message_fields = [field for field in message.DESCRIPTOR.fields_by_name]
    

提交回复
热议问题