Possible Bug: `.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE)` doesnt respect the naming strategy
See original GitHub issueDescribe the bug
I am declaring a global ObjectMapper as such:
val OBJECT_MAPPER = ObjectMapper()
.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE)
.registerKotlinModule()
.registerModule(JavaTimeModule())
.registerModule(ProtobufModule())
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.setSerializationInclusion(JsonInclude.Include.NON_NULL)
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
This worked prior to upgrade to 2.12.5 using
val OBJECT_MAPPER = ObjectMapper()
.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE) <---- notice the deprecated usage
...
However, now when I use something like fun GeneratedMessageV3.toProcedureObject() = OBJECT_MAPPER.writeValueAsString(this)
, the naming strategy is no longer respected. It is using camelCase instead.
I cant figure out why; Ive tracked it to where it shows the naming strategy (which shows correctly), but thats as far I was able to get.
Version information
2.12.5, upgrading from 2.11.4
To Reproduce Using the above setup, it doesnt serialize correctly.
Additional context
Kotlin 1.5.31
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Custom PropertyNamingStrategy not working in jackson
But it seems like that mu NamingStratergy is not working and it is not able to convert the snake_case to camel case and...
Read more >ObjectMapper.setPropertyNamingStrategy - Java - Tabnine
public void setNamingStrategy(PropertyNamingStrategy naming) { setPropertyNamingStrategy(naming);
Read more >Deserialize Snake Case to Camel Case With Jackson
As Java usually uses camel case field naming by convention, this makes it harder to deserialize snake case JSON. We look at some...
Read more >Ditching Gson's Field Naming Strategy | by Sebastiano Gottardo
The lack of annotations ... Gson normally uses the member name as the JSON key, but by using @SerializedName you can provide a...
Read more >How to Use PropertyNamingStrategy in Jackson
Jackson follows standard bean convention in mapping json fields to java object fields , but if you have a json which does not...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@michielboekhoff I agree. I opened up an issue to release out
jackson-datatype-protobuf
with the latest of whats in there.@minxylynx -
I’m pretty sure this is an issue with the ProtobufModule, which is something we ran into as well. Specifically, support for the new
PropertyNamingStrategies
has been implemented in master (see also here) however, it has not been released to mvncentral yet.Therefore, I think this issue can actually be closed & an issue should be opened against the repo for
jackson-datatype-protobuf
.