What is the most elegant way to convert a hyphen separated word (e.g. “do-some-stuff”) to the lower camel-case variation (e.g. “doSomeStuff”)?

后端 未结 11 959
清歌不尽
清歌不尽 2020-11-28 07:16

What is the most elegant way to convert a hyphen separated word (e.g. \"do-some-stuff\") to the lower camel-case variation (e.g. \"doSomeStuff\") in Java?

11条回答
  •  长情又很酷
    2020-11-28 07:58

    For those who has com.fasterxml.jackson library in the project and don't want to add guava you can use the jaskson namingStrategy method:

    new PropertyNamingStrategy.SnakeCaseStrategy.translate(String);
    

提交回复
热议问题