10分钟
4.8.4 获取类型信息
在获取到方法的参数和返回值类型之后,还可以继续查看类型的信息。下面是用describe命令查看参数HelloService.String类型的信息:
$ grpcurl -plaintext localhost:1234 describe HelloService.String
HelloService.String is a message:
{
"name": "String",
"field": [
{
"name": "value",
"number": 1,
"label": "LABEL_OPTIONAL",
"type": "TYPE_STRING",
"options": {
},
"jsonName": "value"
}
],
"options": {
}
}json信息对应HelloService.String类型在Protobuf中的定义如下:
message String {
string value = 1;
}输出的json数据只不过是Protobuf文件的另一种表示形式。
学员评价