使用 Spring WebClient 反序列化整数列表
Deserializing a list of ints with Spring WebClient
我正在尝试与 returns 一个简单的 JSON 整数数组的 Rest 服务进行通信,例如
[1, 2, 3, 4]
我有以下代码通过 WebClient 进行调用:
client.get()
.uri("/achievements")
.retrieve()
.bodyToFlux<Int>()
.doOnNext { println(it) }
.doOnError { it.printStackTrace() }
.blockLast()
然而,Spring returns 我是一个空的 Flux。如果我用 bodyToMono<List<Int>>
替换 bodyToFlux
调用,那么 Spring 能够按预期反序列化响应。缺点是我必须手动将它改回带有冗余 flatMapIterable { it }
的 Flux
我是不是遗漏了什么,或者 bodyToFlux
和 bodyToMono
仅适用于 Jackson POJO?
这是 Spring 的 WebClient 实现中的一个 bug。
我正在尝试与 returns 一个简单的 JSON 整数数组的 Rest 服务进行通信,例如
[1, 2, 3, 4]
我有以下代码通过 WebClient 进行调用:
client.get()
.uri("/achievements")
.retrieve()
.bodyToFlux<Int>()
.doOnNext { println(it) }
.doOnError { it.printStackTrace() }
.blockLast()
然而,Spring returns 我是一个空的 Flux。如果我用 bodyToMono<List<Int>>
替换 bodyToFlux
调用,那么 Spring 能够按预期反序列化响应。缺点是我必须手动将它改回带有冗余 flatMapIterable { it }
我是不是遗漏了什么,或者 bodyToFlux
和 bodyToMono
仅适用于 Jackson POJO?
这是 Spring 的 WebClient 实现中的一个 bug。