My project already has an ObjectMapper defined, as follows
final ObjectMapper mapper = new ObjectMapper();
// some other settings here
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
Most classes in my project in fact use SNAKE_CASE, and everything's peachy. Now I have a class that the downstream returns in lower camel case. I tried using @JsonNaming(PropertyNamingStrategy.LowerCamelCaseStrategy) on my class. If it existed that'd work, but nothing like that seems to exist inside PropertyNamingStrategy.
All I find referencing lower camel case is the constant PropertyNamingStrategy.LOWER_CAMEL_CASE which is only used like in the top snippet it seems, and I definitely don't want to override the project settings here, since almost all classes use snake case.
Of course, I could slap a @JsonProperty('propertyInLowerCamelCase') on every property in the class, but there's quite a few, and that seems like it shouldn't be necessary.
To enforce lowerCamelCase, you can use the annotation
@JsonNaming(PropertyNamingStrategy::class)
This enforces the default naming strategy (lowerCamelCase) and overrides a globally configured naming strategy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With