Im using camel and jackson for unmarshalling string with json
{"GUID":"123"}
... .unmarshal().json(JsonLibrary.Jackson, TestPojo.class)
And hava pojo
TestPojo {
@JsonProperty("GUID)
private String guid;
@JsonProperty("GUID")
public String getGuid(){
return guid;
}
@JsonProperty("GUID")
public String setGuid(){
return guid;
}
}
But have this exception:
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "GUID" (class package.TestPojo), not marked as ignorable (1 known properties: "guid")
Im tested route with processor, which work fine
.process(e -> {
ObjectMapper mapper = new ObjectMapper();
e.getIn().setBody(mapper.readValue(e.getIn().getBody(String.class),TestPojo.class));
})
What im doing wrong?
Your setguid is returning the guid in lowercase. However, in the json body, the guid is capitalized (GUID). Try to capitalize the guid or set.
public void setGUID(String GUID){
this.GUID = GUID
}