title: Spring Reactive get body JSONObject using ServerRequest
body: <p>i'm spring reactive newbie.</p>
  
  <p>I am trying to use postman to get request information from the server.</p>
  
  <p>First, postman sends information to the server using the post method.
  Second, we've been working on the server side with the relevant code and getting the request information.      </p>
  
  <p>In the following code snippet</p>
  
  <p>I wonder if I can get the JSONObject of the ServerRequest function.</p>
  
  <p>postman body(application/json)</p>
  
  <pre><code>{
      "name": "aaaa",
      "name_order": ["aa", "bb", "cc"],
      "type": "12",
      "query": ""
  }
  </code></pre>
  
  <p>java (RouterFunction)</p>
  
  <pre><code>import com.ntels.io.input.handler.RestInHandler;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.http.MediaType;
  import org.springframework.web.reactive.config.EnableWebFlux;
  import org.springframework.web.reactive.config.WebFluxConfigurer;
  import org.springframework.web.reactive.function.server.*;
  
  import static org.springframework.web.reactive.function.server.RequestPredicates.GET;
  import static org.springframework.web.reactive.function.server.RequestPredicates.POST;
  import static org.springframework.web.reactive.function.server.RequestPredicates.PUT;
  import static org.springframework.web.reactive.function.server.RequestPredicates.DELETE;
  
  @Configuration
  @EnableWebFlux
  public class RestConfig implements WebFluxConfigurer {
  
      @Bean
      public RouterFunction&lt;ServerResponse&gt; routes(RestInHandler restInHandler){
          return RouterFunctions.route(POST("/input/event").
          and(RequestPredicates.accept(MediaType.APPLICATION_JSON)), restInHandler::toRESTInVerticle);
      }
  }
  </code></pre>
  
  <p>java (Handler)</p>
  
  <pre><code>public Mono&lt;ServerResponse&gt; toRESTInVerticle(ServerRequest serverRequest) {
      String serverRequestUrl = serverRequest.uri().toString();
  
      System.out.println("RestInHandler test in");
      System.out.println(serverRequest.method());
      System.out.println(serverRequest.headers());
      System.out.println(serverRequest.uri().toString());
  
      // how can i get the jsonbody using serverrequest
  
      // testing..
  
      // Mono&lt;JSONObject&gt; jsonObjectMono = serverRequest.bodyToMono(JSONObject.class);
      // Flux&lt;JSONObject&gt; jsonObjectFlux = serverRequest.bodyToFlux(JSONObject.class);
  -&gt; MonoOnErrorResume
  
      return (Mono&lt;ServerResponse&gt;) ServerResponse.ok();
  }
  </code></pre>