【发布时间】:2020-02-03 13:20:50
【问题描述】:
我的 PB 架构如下所示:
message ProductRecommendationReply {
string productid = 1;
message recommendationlist{
string recommendedproductid = 1;
string recommendedproductname = 2;
string recommendedproductprice = 3;
}
}
在服务器端(node.js),我正在尝试设置如下属性:
var message = {
productid: '',
recommendationlist: []
};
message.productid = result_list.product_Id;
message.recommendationlist.recommendedproductid = result_list.recomendation_list[0].recommended_product_id;
message.recommendationlist.recommendedproductname = result_list.recomendation_list[0].recommended_product_name;
message.recommendationlist.recommendedproductprice = result_list.recomendation_list[0].recommended_product_price;
callback(null,message); // send the result back to consumer.
问题是调试clinet端时,只有productid有赋值,recommendationlist是空的。
如何正确地为嵌套消息赋值?
【问题讨论】:
标签: javascript protocol-buffers grpc