-
Notifications
You must be signed in to change notification settings - Fork 9
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
Convert dash case to camel case #8
Comments
Sorry, my fault, I was fooling around. Hope you understand. |
jotaporras
changed the title
Convert Dash case to camel case
Convert dash case to camel case
May 2, 2016
Have you tried using jackson's KebabCaseStrategy? |
I'm not sure if this is what you want, but... val HOCON_MAPPER = ObjectMapper(HoconFactory()).apply {
this.enable(MapperFeature.ALLOW_EXPLICIT_PROPERTY_RENAMING)
this.propertyNamingStrategy = object: PropertyNamingStrategy.PropertyNamingStrategyBase() {
override fun translate(p0: String): String {
val newField = StringBuilder()
for (ch in p0) {
if (ch.isUpperCase()) {
newField.append('-')
}
newField.append(ch.toLowerCase())
}
return newField.toString()
}
}
} This allows you to use properties with camelCase while the source config (in HOCON) uses class TestConfig(
@JsonProperty("camelCaseParam")
val camelCaseParam: String
) val testConfig = Constants.HOCON_MAPPER.readValue<TestConfig>("camel-case-param = hello world")
println(testConfig.camelCaseParam) displays |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When parsing HOCON, the mapper does not recognize dash case (e.g. 'sample-key: "a"') to convert it to camel case ('sampleKey')
PS: Sorry for the previous title. My co-worker was messing with my computer.
The text was updated successfully, but these errors were encountered: