谷歌协议缓冲区:如何定义消息包含ArrayList <arraylist <string>&gt;在proto文件中

时间:2018-05-30 20:21:58

标签: java protocol-buffers rpc grpc google-protocol-buffer

ArrayList对应重复的字符串:

message m1 {
    repeated string mylist = 1;
}

如何定义ArrayList&lt;的ArrayList&LT;串GT; &GT;在消息? 谢谢!

1 个答案:

答案 0 :(得分:2)

您需要另一条消息来表示内部列表。

ArrayList<ArrayList<String>>

当然,您可以向M2添加任意数量的字段,并且您需要一些单独的转换逻辑来将message M1 { repeated StringList mylist = 1; } message StringList { repeated string value = 1; } 汇总到var router = express.Router(); const MongoCient = require('mongodb').MongoClient; const dbName = 'myproject'; const url = 'mongodb://localhost:27017'; router.get('/get/:id', function (req, res) { var param = req.params.id; var myQuery = { "content-transition":param }; MongoClient.connect(url, function(err, client) { var collection = client.db(dbName).collection('documents'); var result = collection.find({myQuery}); console.log(result) }); });

您甚至可能希望创建一个可重用的消息来表示字符串列表:

nvidia-docker run -dit -v host_dir:docker_local_dir -p 5000:8080 --name  Test_Container --privileged Test_Image /bin/bash