title: How do I have two identical json property names assigned to two separated fields
body: <p>I have the following Java class <a href="https://i.stack.imgur.com/GBD2d.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GBD2d.png" alt="enter image description here" /></a></p>
  <p>I need to serialize it to json in the following way:</p>
  <p>if the list(paymentTransactionReport field) is not null display it values -</p>
  <pre><code>{ 
  &quot;paymentTransactionResponse&quot; : [
      {},
      {}
    ]
  }
  </code></pre>
  <p>if the list is null I need to display the paymentTransactionReportError in json field with name 'paymentTransactionResponse', as in previous case. Example -</p>
  <pre><code>{
  &quot;paymentTransactionResponse&quot; : {
  ----
  //fields from PaymentTransactionReportError class
  ----
    }
  }
  </code></pre>
  <p>How can I do this?preferably without custom serializers.
  If use just two annotations @JsonProperty with the same name and JsonInclude.NON_NULL as I did, I have this error: No converter found for return value of type:... Seems to be that is a error happened during serialization because of fields with the same name</p>