我正在尝试使用 Spring RestTemplate 使用 REST api,这几乎是我想要做的:
public ResponseEntity<OfficeProto.Offices> getAllOffices() {
return restTemplate.exchange(uri, HttpMethod.GET, httpEntity, new ParameterizedTypeReference<OfficeProto.Offices>() {});
}
以下是源 json 的样子,我如何在 protobuf 中表示一个未命名的列表?
[
{
"name": "Office 1"
},
{
"name": "Office 2"
}
]
这就是我的.proto
文件的样子
syntax = "proto3";
option java_outer_classname = "OfficeProto";
message Office {
string name = 1;
}
message Offices {
repeated Office office = 1;
}
我收到以下错误:
org.springframework.web.client.RestClientException: Error while extracting response for type [class com.findwise.connect.OfficeProto$Offices] and content type [application/json]; nested exception is com.googlecode.protobuf.format.JsonFormat$ParseException: 1:1: Expected "{".