Deserialize a json array to objects using Jackson and WebClient

前端 未结 3 1771
失恋的感觉
失恋的感觉 2020-12-31 02:53

I have a problem during the deserialization of a json array using Spring. I have this json response from a service:

[
    {
        \"symbol\": \"XRPETH\",
          


        
3条回答
  •  萌比男神i
    2020-12-31 03:15

    Regarding your updated answer to your question, using bodyToFlux is unnecessarily inefficient and semantically doesn't make much sense either as you don't really want a stream of orders. What you want is simply to be able to parse the response as a list.

    bodyToMono(List.class) won't work due to type erasure. You need to be able to retain the type at runtime, and Spring provides ParameterizedTypeReference for that:

    bodyToMono(new ParameterizedTypeReference>() {})
    

提交回复
热议问题