title: Spring boot / Jackson deserializes JSON of wrong type
body: <p>I'm a litte bit lost, I have to admit. I wrote a Spring Boot (1.3M2) application that receives a JSON object which it needs to store in a database:</p>
  
  <pre><code>@RequestMapping(value = "/fav", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
      @ResponseBody
      public ResponseEntity&lt;String&gt; setFavorite(@RequestBody List&lt;Favorite&gt; favorites) {
  ...
  </code></pre>
  
  <p>internally this method passes the JSON to another method which stores it line by line in a database:</p>
  
  <pre><code>jdbcTemplate.batchUpdate(INSERT_FAVORITE, new BatchPreparedStatementSetter() {
                  @Override
                  public void setValues(PreparedStatement ps, int i) throws SQLException {
                      Favorit fav = favorites.get(i);
                      ps.setString( ...
                  }
  
                  @Override
                  public int getBatchSize() {
                      int size = favorites.size();
                      return size;
                  }
  </code></pre>
  
  <p>When I POST a JSON to the controller which does not match the structure of my Favorite-object I only see null values in my database. Obviously Jackson tries its best to convert my JSON into a Java object but fails and sets all values of the object it finds no value for to null.
  Then this list of sort of empty objects is written to the database.</p>
  
  <p>I use curl to POST the values</p>
  
  <pre><code>curl -vX POST https://localhost/fav -d @incorrectype.json 
  </code></pre>
  
  <p>This can't be the source of error because it works with a favorite.json. How can I have my controller / Jackson detect if I use a JSON that does not match ?</p>