- 一、场景
- 二、proto文件内容
- 三、解决
- Micro Web 接口请求,传参内容如下
{"ids": 1}
- 报错:cannot unmarshal number into Go value of type []json.RawMessage
- 翻译:无法将数字解编为类型为[]的Go值json.RawMessage
- 分析:不能把数字解析为[],应该是要传数组[1],而不是传数字1
message GoodsRequest {
int64 id = 1;
repeated int64 ids = 2;
double sale_price = 3;
string desc = 4;
repeated GoodsSku tags = 5;
}
message GoodsSku {
int64 id = 1;
int64 goods_id = 2;
string name = 3;
int64 type= 4;
double market_price = 5;
}
三、解决
- 参数方式传错了,正确的方式为:
{"ids": [1, 2]}
- id的传参方式如下:
{"id": 1}


![golang:cannot unmarshal number into Go value of type []json.RawMessage golang:cannot unmarshal number into Go value of type []json.RawMessage](http://www.mshxw.com/aiimages/31/944689.png)
