Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
347 views
in Technique[技术] by (71.8m points)

java - Serialization problem with "is getter" to property name in jackson databind

I have a problem with serialization of "is getter" accessor to property name. I have a class with boolean isState() accessor method and property with name isState.

enter image description here

During serialization I see that object mapper is convert isState() method as state property.

enter image description here

Of course I can use @JsonProperty annotation but I need to do it generically for all such cases.

Before jackson-databind 2.12.0 it worked, unfortunately it stopped now because AccessorNamingStrategy has been added with a new way to find field names for getters. I can extend the AccessorNamingStrategy class and change the way to find field names, but it's too much code duplication to achieve such a minor goal. Issue: Extract getter/setter/field name mangling from 'BeanUtil' into pluggable 'AccessorNamingStrategy'

I tried to fight setAccessorNaming because it came out from version 2.12.0 and setPropertyNamingStrategy but unfortunately with poor results.

Edit:

I was able to fix the problem like this (image), if anyone has something better please let me know.

enter image description here

question from:https://stackoverflow.com/questions/65876901/serialization-problem-with-is-getter-to-property-name-in-jackson-databind

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...