I am working on Java Object to JSON conversion using ObjectMapper but it is giving extra attribute which is not present in my java class.
Below is the Java Object Builder class.
@JsonDeserialize(builder = OrderSummary.Builder.class)
public class OrderSummary extends ABC {
@JsonProperty("orderCode")
private String orderCode;
@JsonProperty("transactionAmount")
private long transactionAmount;
@JsonProperty("transactionCurrency")
private String transactionCurrency;
@JsonProperty("isPayout")
private boolean isPayout;
private OrderSummary(Builder builder) {
super(builder);
orderCode = builder.orderCode;
transactionAmount = builder.transactionAmount;
transactionCurrency = builder.transactionCurrency;
isPayout = builder.isPayout;
}
public static Builder newBuilder() {
return new Builder();
}
public String getOrderCode() {
return orderCode;
}
public long getTransactionAmount() {
return transactionAmount;
}
public String getTransactionCurrency() {
return transactionCurrency;
}
public boolean isPayout() {
return isPayout;
}
@JsonPOJOBuilder
public static final class Builder extends ABC.Builder<Builder> {
private String orderCode;
private long transactionAmount;
private String transactionCurrency;
private boolean isPayout;
private Builder() {
}
public Builder withOrderCode(String val) {
orderCode = val;
return this;
}
public Builder withTransactionAmount(long val) {
transactionAmount = val;
return this;
}
public Builder withTransactionCurrency(String val) {
transactionCurrency = val;
return this;
}
public Builder withIsPayout(boolean val) {
isPayout = val;
return this;
}
public OrderSummary build() {
return new OrderSummary(this);
}
@Override
protected Builder self() {
return this;
}
}
}
It extends 1 class which has only 2 attributes
- transaction code
- unique identifier
But when I have using Object Mapper object to convert to json getting below json
{
"payout": false,
"transactionCode": "ABCJD",
"uniqueIdentifier": 78632,
"orderCode": "12345",
"transactionAmount": 1200,
"transactionCurrency": "EUR",
"isPayout": false,
}
I am not sure how "payout": false, is added in json.
I tried converting another java object which does not have boolean it is working fine without any issue.
Can you please help me in how can I fix this conversion.