You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何自动解析代码中使用的Protobuf(trade.proto)字段?

从给定代码中提取Protobuf字段的方法

直接通过代码里的getter方法反向对应Protobuf字段即可——Protobuf生成代码时会把proto里的下划线命名转成驼峰式的getter方法,对应规则如下:

  • 代码中的trade.getPartitionTime,对应proto文件里的partition_time字段
  • 代码中的trade.getProductInfo.getOtherFieldList,对应proto里嵌套的product_info.other_field字段(因为该字段是repeated类型,生成的方法会带List后缀)

最终提取出的代码用到的Protobuf字段:

partition_time
product_info.other_field

内容的提问来源于stack exchange,提问作者Birkety

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.10 00:40:23