-
Notifications
You must be signed in to change notification settings - Fork 175
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
First two characters of property name must be lowercase due to Java restrictions #92
Comments
Have you tried enabling |
I have now, and it doesn't seem to change anything.
It also looks like, even if it had worked, this is going away in 3.0. |
Yes, feature goes away because it becomes default, and there is no real reason to support previous (2.x) behavior since it was not compatible with Bean naming (for specific case of more than one leading capital letters). But it sounds like this is not related to name mangling core databind does, given that behavior does not change. Apologies for noise if this is the case. Just thought it is good to eliminate one possibility. |
I debugged this today and it occurs because of an inconsistency in how Kotlin names things, which is not handled in how The class definition:
produces something resembling this Java:
As you can see, there is an inconsistency between the field name and the getter (or the constructor argument). Changing to use standard bean naming doesn't help, because then instead of |
@robpridham-bbc Ah. Yes, I see the issue. Thank you for debugging this further. From Jackson perspective names are inconsistent.... Bean naming would get |
This is related to other issues reported here, Kotlin generates setter/getters and those do not match the naming in the constructor parameter. It is hard to align everything in a way that Jackson would accept. The only guaranteed way is to use |
I ran into the exact same problem today. Any workarounds that one can use for this? |
Only using |
Use the For example: |
This can be useful: |
I discovered today by chance that an old restriction from Java means that you cannot have uppercase characters in the first two characters of a JSON/Kotlin property.
Consider this self-contained test case:
The first test fails and the second passes.
This is because of this and by reference this.
However in the world of Kotlin, we are several steps removed from Java beans or indeed the underlying setters/getters that Kotlin automatically generates, and this behaviour doesn't make a great deal of sense. It was only by accident that I discovered it.
Please consider whether there's an opportunity to bypass this issue via the Kotlin module.
The text was updated successfully, but these errors were encountered: