java
java copied to clipboard
Unable to data-bind when using java-library to bind json to java-object with "case" difference in json field and class fields
When mapping my JSON below
"{ \"ApprovalStatus\": 3, \"ApproverName\": \"Hi\" }"
to my java object defined as below
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.Setter;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"ApprovalStatus",
"ApproverName"
})
@Getter
@Setter
public class ItineraryJsonIter {
@JsonProperty ("ApprovalStatus")
public Long approvalStatus;
@JsonProperty ("ApproverName")
public String approverName;
}
However because of the case difference in JSON and class-member it does not get mapped properly, any idea what needs to be done here?
I am using following in my build dependencies
//JSON-ITER Based Parsing
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.11.0'
// Required if generating JSR-303 annotations
compile 'javax.validation:validation-api:1.1.0.CR2'
// Required if generating Jackson 2 annotations
compile 'com.fasterxml.jackson.core:jackson-databind:2.11.0'
// Required if generating JodaTime data types
compile 'joda-time:joda-time:2.2'
compile group: 'com.jsoniter', name: 'jsoniter', version: '0.9.23'
//End JSON-ITER Based Parsing