我想创建一个代表对象数组的 protobuf 消息。
示例
[
{
"firstKey": "firstValue",
"secondKey": "secondValue",
},
{
"firstKey": "firstValue",
"secondKey": "secondValue",
},
...
]
伪代码(不是有效的语法)
syntax = "proto3";
message Entry {
string firstKey = 1;
string secondKey = 2;
}
repeated message Response {
...Entry;
}
我找不到办法做到这一点。有可能吗?还是我被迫像这样嵌套它?
syntax = "proto3";
message Entry {
string firstKey = 1;
string secondKey = 2;
}
message Response {
repeated Entry data = 2;
}
最佳答案
syntax = "proto3";
message SingleObject {
string name = 1;
int32 age = 2;
}
message ObjectArray {
repeated SingleObject objects = 1;
}
关于json - 将对象数组表示为 protobuf 消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69243156/