title: Parse RequestBody as two different objects in Spring boot
body: <p>In my Spring Boot application (<code>2.5.5</code>) I get a large JSON body in the <code>POST</code> request to a specific endpoint. On that request I need to get both the parsed object and that whole object as a string to do some validation. The JSON object contains a lot of information that I don't need so that is not included in the Object so I can't convert it to a string.</p>
  <pre><code>@RestController
  @RequestMapping(&quot;/example&quot;)
  public class ExampleController {
  
      @PostMapping(&quot;&quot;)
      public void example(
          @RequestBody String stringBody,
          @RequestBody ExampleRequest exampleRequest
      ) {
          // Validate request with 'stringBody'
          // Do things with 'exampleRequest'
      }
  
  }
  </code></pre>
  <p>The best idea I had so far is to just use <code>@RequestBody String stringBody</code> and then convert that string to a JSON object but that is really not the ideal solution.</p>
  <p>I know that you can't have two <code>@RequestBody</code> but I really need to somehow have both.</p>