title: Can Spring MVC deserialize JSON which can be object or array?
body: <p>I have controller receiving JSON in request body, which can be object or array of objects. For example:</p>
  
  <pre><code>{
    "id" : 1,
    "name" : "Nick",
    "surname" : "Cave"
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>[
   {
     "id" : 1,
     "name" : "Nick",
     "surname" : "Cave"
   },
   {
     "id" : 2,
     "name" : "Jack",
     "surname" : "White"
   }
  ]
  </code></pre>
  
  <p><strong>Is there any way to force Spring to deserialize JSON to object in the similar way to object alone?</strong></p>
  
  <pre><code>@RequestMapping(value = "/", method = RequestMethod.POST)
  public void postController(@RequestBody User user, ...) {
     ...
  }
  </code></pre>
  
  <p>If not, what is the elegant way of parsing and validating those kind of messages?</p>