【发布时间】:2018-07-24 05:03:00
【问题描述】:
我有这样的格式,想把我的 python dict 转换成这个 proto 格式 原型代码:
message template{
message NicSettings{
string network_adapter = 1;
string network_name = 2;
}
message NetConfig{
bool keep_mac_address =1;
bool same_as_source = 2;
repeated NicSettings nic_settings = 3;
}
NetworkConfig network_config = 3;
}
python 字典:
template:
{ keepMacAddress: true,
sameAsSource : false,
nicSettings: [ {networkAdapter: "ethernet0",
networkName: "Calpal1"
} ,
{networkAdapter: "ethernet1",
networkName: "Calpal2"
}
]
}
如何将其转换为 proto 消息以将其传递给 gRPC。
【问题讨论】: