(Discussed in https://github.com/FasterXML/jackson-databind/discussions/5289 )
Originally posted by @bananayong August 31, 2025
Recently I read the cowtowncoder blog First, thank you for releasing the most wanted features!
I thought that it would be possible to use FIX_FIELD_NAME_UPPER_CASE_PREFIX feature
with ParameterNamesModule
.
However, I ran some tests, and it didn't work.
static class Apple {
private final String iPhone;
public Apple(String iPhone) {
this.iPhone = iPhone;
}
public String getIPhone() {
return iPhone;
}
@Override
public String toString() {
return "Apple{" +
"iPhone='" + iPhone + '\'' +
'}';
}
}
public static void main(String[] args) throws JsonProcessingException {
ObjectMapper mapper = JsonMapper.builder()
.addModule(new ParameterNamesModule())
.enable(MapperFeature.FIX_FIELD_NAME_UPPER_CASE_PREFIX)
.build();
Apple apple = new Apple("iPhone 15");
String json = mapper.writeValueAsString(apple);
System.out.println(json); // {"iPhone":"iPhone 15"}
Apple result = mapper.readValue(json, Apple.class); // Error thrown
System.out.println(result);
}
It seems like the property name is determined by the constructor parameter and FIX_FIELD_NAME_UPPER_CASE_PREFIX
feature is not applied. Is that intended? Or will it be improved in the next release?