Guava
is famous for mutual conversion of naming conventions in Java
such as camel case and snake case, but Jackson
can also do it, so I will summarize it.
You can do this by using the various Strategy
s defined in com.fasterxml.jackson.databind.PropertyNamingStrategy
.
As an example, here is the conversion from camel case to snake case.
public static String camelToSnake(String value) {
return new PropertyNamingStrategy.SnakeCaseStrategy().translate(value);
}
See the source code and documentation for other conversions.
As another method, ModelMapper
and Gson
are likely to have equivalent functions.
-Java -Map and Bean conversion with snake case key | teratail
-Jackson's Property Naming Strategy Summary -Qiita
Recommended Posts