Skip to content
Advertisement

spring-webflux : How to Extract user defined object from Mono or Flux from the response without blocking?

getUserDetails Method returns Mono of Type JsonNode. But I Actually want to return a Mono<User.java> or Flux<User.java>. please help modifying getBulkUserInfo or getUserDetails to get the Mono<User.java> or Flux<User.java>

JavaScript

But The json response from the Url is something like

JavaScript

I tried different ways but nothing worked subscribe() and .doOnNext(resp -> resp.get(“resultholder”).get(“profiles”).get(“profileholder”).get(“user”))

JavaScript

Advertisement

Answer

This is pretty straightforward and there is no need to block. Its just applying further mappings on the response. You can use the following code for your problem

JavaScript

Where mapper is jackson ObjectMapper

private final ObjectMapper mapper = new ObjectMapper();

If you have any issues please refer to this code here :

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement