Spring WebClient を使用して、JSON として応答を返す REST API を呼び出しています。応答の構造は次のとおりです。
{
"vehicles":[
{ "name":"veh1", "type":"car", "age": 5 },
{ "name":"veh2", "type":"speedboat", "age":12},
.....
]
"metadata": {
"token":"abcd",
"days":120
}
}
私はリアクティブ プログラミングの初心者です。問題なく動作する次のコードを書きました。
Mono<VehicleResponse> = webclient.get()
.uri("/legacy/vehicles")
.accept(MediaType.APPLICATION_JSON)
.retrieve()
.onStatus(HttpStatus::is4xxClientError, clientResponse -> Mono.empty())
.onStatus(HttpStatus::is5xxServerError, clientResponse -> Mono.empty())
.bodyToMono(VehicleResponse.class);
しかし、実際に私が興味を持っているのは、車両配列のみです(メタデータ情報は必要ありません)。車両(配列)のみを Flux of Vehicle として取得/読み取ることは可能ですか?