title: Creating JSON from httprequest and then parsing it
body: <p>In my controller I want to parse httprequest (JSON sent by me) to create new ToDoItem. I will shoot POST at localhost:8080/todos/new with JSON and my controller should turn that httprequest to JSON and then parse data from it and use it in the contructor.
  Here is my code so far:</p>
  
  <pre><code>// CREATE NEW TODOITEM FROM SENT JSON
  @PostMapping("/todos/new")
  public ResponseEntity&lt;ToDoItem&gt; newToDo(
          @RequestBody ToDoItem toDoItem,
          Principal principal
  ) {
      User currentUser = userRepository.findByUsername(principal.getName());
      toDoItemService.addToDo(toDoItem, currentUser);
      return ResponseEntity.ok(toDoItem);
  }
  </code></pre>
  
  <p>Btw what would be the best choice to use as Date here? Is Calendar ok? Talking about parsing and sending it in a JSON.</p>
  
  <p>EDIT:
  My entity with annotations (setters and getters ommited):</p>
  
  <pre><code>@Entity
  @Table (name = "TO_DO_ITEMS")
  public class ToDoItem extends BaseEntity {
  
  @Column(name = "TITLE", nullable = false)
  private String title;
  
  @Column(name = "COMPLETED")
  private boolean completed;
  
  @Column(name = "DUE_DATE", nullable = false)
  @JsonDeserialize(using = LocalDateDeserializer.class)
  @JsonSerialize(using = LocalDateSerializer.class)
  protected LocalDate dueDate;
  
  // a ToDoItem is only associated with one user
  @ManyToOne(cascade=CascadeType.PERSIST)
  @JoinColumn(name = "USER_ID")
  private User user;
  
  
  // JPA demands empty constructor
  public ToDoItem() {}
  
  public ToDoItem(User user, String title, LocalDate dueDate) {
      this.user = user;
      this.title = title;
      this.dueDate = dueDate;
  }
  </code></pre>
  
  <p>And when I send: </p>
  
  <pre><code>{
  "title":"testtodo",
  "dueDate": [
      2017,
      10,
      06
  ]
  }
  </code></pre>
  
  <p>I get Bad Request error:</p>
  
  <pre><code>{
  "timestamp": 1485948636705,
  "status": 400,
  "error": "Bad Request",
  "exception":     "org.springframework.http.converter.HttpMessageNotReadableException",
  "message": "Could not read document: Invalid numeric value: Leading  zeroes not allowed\n at [Source: java.io.PushbackInputStream@4f15b887;   line: 6, column: 4]\n at [Source: java.io.PushbackInputStream@4f15b887;  line: 6, column: 3] (through reference chain:  com.doublemc.domain.ToDoItem[\"dueDate\"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Invalid numeric  value: Leading zeroes not allowed\n at [Source: java.io.PushbackInputStream@4f15b887; line: 6, column: 4]\n at [Source: java.io.PushbackInputStream@4f15b887; line: 6, column: 3] (through reference chain: com.doublemc.domain.ToDoItem[\"dueDate\"])",
  "path": "/todos/new"
  }
  </code></pre>