Conversation
8c601fc to
a543a40
Compare
|
Hope this will be merged soon! |
| trait SnakeCaseJsonSupport extends DefaultJsonProtocol { | ||
|
|
||
| override protected def extractFieldNames(classTag: ClassTag[_]): Array[String] = { | ||
| def snakify(name: String) = { |
There was a problem hiding this comment.
Maybe we should also just use the regex here? Performance shouldn't be an issue as the formats are usually only evaluated once per type.
| val sampleFields2 = SampleFields2().toJson.asJsObject | ||
| // Then | ||
| val fields1 = sampleFields1.fields | ||
| fields1.contains(snakify("HelloWorld")) mustEqual true |
There was a problem hiding this comment.
Good that snakify is a different implementation here in the test, but I would prefer if the test case expectations would be spelled out.
| val sampleFields2 = SampleFields2().toJson.asJsObject | ||
| // Then | ||
| val fields1 = sampleFields1.fields | ||
| fields1.contains(snakify("HelloWorld")) mustEqual true |
There was a problem hiding this comment.
Good that snakify is a different implementation here in the test, but I would prefer if the test case expectations would be spelled out.
There was a problem hiding this comment.
E.g. like this:
| fields1.contains(snakify("HelloWorld")) mustEqual true | |
| fields1 must haveKey("hello_world") |
|
@plokhotnyuk I also tried your implementation. But some of the behavior is unexpected for me in some corner case. ex)
It is difficult to judge which is better because there aren't standard specification for this conversion, as far as I know. |
Close #170