-
Notifications
You must be signed in to change notification settings - Fork 666
Add @HoconName annotation #3013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
| } | ||
|
|
||
| @Test | ||
| fun testDeserializeUsingSerialNameInsteadOfNamingConvention() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test was successful only because the value in @SerialName is follow the naming convention 😄
I think it is confusing and not helpful to check anything.
|
@sandwwraith, have I a chance to get review and merge this fix? |
|
I'm a little bit hesitant to add this annotaiton for Hocon, since we do not have a Json equivalent; if same problem arises in Json (it is there for JsonNamingStrategy, for example), maybe we would need a better generalized solution. What are benefits of having this annotation instead of just disabling "useHoconNamingConvention"? Or maybe we need a specific annotation, e.g., |
I don't want to disable this naming convention, because 99% of the fields follow this convention. However, we also need the ability to set a serial name manually from time to time. 🤷♂️
Yes, potentially this solves the problem by using two annotations per field, but it doesn't look so good either. 🤔 @Serializable
data class (
@DisableHoconConvention
@SerialName("unConventionField")
val unConventionField: String
)
Do you mean the situation where one type can be serialized in multiple formats?
We have the |
|
I have looked the options for not having per-format naming annotations. I am not sure that those annotations can be avoided if you want to be able to use the same serializers for different formats (with potentially different names). Even if a functional strategy is used, it would often have to resort to either a built-in translation table or custom annotations. |
It works for deserialization alone. |
Current implementation doesn't give users any chance to control the property name in Hocon representation when they use the
useConfigNamingConvention.