-
Notifications
You must be signed in to change notification settings - Fork 48
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
Snake case behavior does not match play-json #82
Comments
I have same issue. Here is a quick test to demonstrate that
I'd love to make my own
|
@caente It looks like you're the committer who has done the most recent release - is there any particular set of instructions for making contributions to this repository? I just wanted to check in since I haven't heard anything in a couple of months. |
For reference, here’s how we’ve been working around this in our projects: import ai.x.play.json.{CamelToSnakeNameEncoder, NameEncoder}
import play.api.libs.json.JsonNaming.SnakeCase
implicit val encoder: NameEncoder = new CamelToSnakeNameEncoder {
// Stock CamelToSnakeNameEncoder behaves differently from SnakeCase:
// see https://github.com/xdotai/play-json-extensions/issues/82
override def encode(str: String): String = SnakeCase(str)
}
|
I was trying to update from using the tototoshi json naming library to using the built-in snake case facility. However, I found out that the behavior of play-json-extensions does not match that or what is in the main play-json library. I think that it would make the most sense if this exactly matched the main play library.
I think the issue lies in how numbers are treated.
play-json would snake case foo12Bar as foo12_bar
play-json-extensions would snake case foo12Bar as foo_1_2_bar
I suggest just having play-json-extensions just delegate to the play library, since the snake case function is public:
https://github.com/playframework/play-json/blob/2.8.1/play-json/shared/src/main/scala/play/api/libs/json/JsonConfiguration.scala#L99
The text was updated successfully, but these errors were encountered: