title: how handle null in nested JSON object?
body: <p>I have Dto with field private Category category2;</p>
  <pre><code>@Entity
  @Getter
  @Setter
  @ToString
  @RequiredArgsConstructor
  @Builder
  @AllArgsConstructor
  
  public class Procurement implements Serializable {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = &quot;id&quot;, nullable = false, unique = true)
      private Long id;
  
      @Column(name = &quot;name&quot;,columnDefinition = &quot;varchar(1000)&quot;)
      private String name;
  
      @Column(name = &quot;category&quot;,columnDefinition = &quot;varchar(1000)&quot;)
      private String category;
  
      @Column(name = &quot;type&quot;,columnDefinition = &quot;varchar(1000)&quot;)
      private String type;
  
      @Enumerated(EnumType.ORDINAL)
      @Column(name = &quot;status&quot;)
      private ProcStatus status;
  
      @OneToOne
      private Category category2;
  </code></pre>
  <p>CategoryDto:</p>
  <pre><code>@Data
  @Builder
  @NoArgsConstructor
  @AllArgsConstructor
  @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
          property = &quot;id&quot;, scope = Long.class)
  public class CategoryDto {
      private Long id;
      private String name;
  }
  </code></pre>
  <p>I have controller and method of create new Procurement:</p>
  <pre><code>@PutMapping
  ResponseEntity&lt;Procurement&gt; createNewProcurement(@RequestBody ProcurementDto procurementDto) {
  
      return ResponseEntity.ok(procurementService.createNewProcurement(procurementDto));
  }
  </code></pre>
  <p>I provide json to controller via fetch in js</p>
  <pre><code>function createnewprocuremet() {
      fetch(`${url}`, {
          method: 'PUT', headers: {'Content-Type': 'application/json'},
          body: JSON.stringify({
              name: name.value,
            category2: {id:$('#categoryprocselector').val()}
          })
      }).then((res) =&gt; {
          return res.json();
      })
          .then((data) =&gt; {
              $table.bootstrapTable('refresh')
              tab.show()
              name.value = ''
        })
          .catch(error =&gt; console.log(error))
  } 
  </code></pre>
  <p>category2 not required and user cannot choose it in selector</p>
  <p>If not select category id:$('#categoryprocselector').val() = null and  send null to controller and i have error org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error</p>
  <p>If category selected it`s work ok.</p>
  <p>How i can handle this exception?</p>