【发布时间】:2020-06-04 06:29:10
【问题描述】:
考虑以下对象的 json 表示
{
"format": "0.0.1",
"has_impl": true,
"mtv_1b": 1,
"mtv_1c": "h",
"ktc_12": true,
"ktc_zz": true,
}
前两个 format 和 has_impl 字段是已知的。此外,对象可能具有任意数量的mtv_XX 和ktc_XX 类似字段。
这样的对象是否可以在 proto3 中表示,您将如何处理?
以下可能是一个明显的起点。是否有oneOf、WellKnownTypes 的组合可以在这里使用?
message MyObject {
string format = 0;
bool has_impl = 1;
// Is there anything that can go in here ?
....
}
【问题讨论】: