I am trying to change the attribute name to snake_case for the response in a model class. The Jsonproperty works fine with DB entity class, but not with the model class which does not have any DB entity mapped. sample code which is not working.
SubtestResult.java -- Modelclass
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
public class SubtestResult {
@JsonProperty("expected_value") @Getter @Setter private String expectedValue;
@JsonProperty("actual_value") @Getter @Setter private List<String> actualValue;
}
Assertion.java
public class assertion {
private SubtestResult calculate(string actualValue){
SubtestResult subtestResult = new SubtestResult();
subtestResult.setActualValue(actualValue);
subtestResult.setExpectedValue("true");
}
Actual result
{
"expectedValue": true
"actualValue": false
}
Expected :
{
"expected_value": true
"actual_value": false
}
Note: There is no DTO entity for this. this entire model object gets stored as a string.