title: ObjectMapper - How to send null value in JSON
body: <p>According to third party API spec, I need to send null value in JSON using <code>ObjectMapper</code> if no value exists,</p>
  
  <p>Expected results : <code>"optional": null</code> </p>
  
  <p>If optional value exists, then send <code>"optional": "value"</code></p>
  
  <p>I didn't find such option in <a href="https://www.baeldung.com/jackson-map-null-values-or-null-key" rel="nofollow noreferrer">Jackson – Working with Maps and nulls</a></p>
  
  <p>Code:</p>
  
  <pre><code>requestVO = new RequestVO(optional);
  ObjectMapper mapper = new ObjectMapper();
  String requestString = mapper.writeValueAsString(requestVO);
  </code></pre>
  
  <p>Class:</p>
  
  <pre><code>public class RequestVO {
     String optional;
     public RequestVO(String optional) {
        this.optional = optional;
     }
  
  public String getOptional() {
      return optional;
  }
  
  public void setOptional(String optional) {
      this.optional= optional;
  }
  </code></pre>