[go: nahoru, domu]

Skip to content
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

Allow case class member names to be customized when deriving the codecs #33

Closed
wants to merge 1 commit into from

Conversation

gcpagano
Copy link
Contributor
@gcpagano gcpagano commented Jun 8, 2016

This is to allow for case class members to be transformed, adapting to custom fields casing in the json.
For example it can be used to convert field names to snake case.

I consider it a first draft, to get some ideas around the possible solution, but it's already working and have added some tests for it.

@julienrf
Copy link
Owner
julienrf commented Jun 8, 2016

Hi, thanks for this work!

I think that’s an interesting feature, however my main concern is that the current design to configure the derivation process is not to use implicits but usual parameters (like tagReads). I think it is preferable for things like that to be explicitly set as regular parameters rather than driven by the implicit scope. I’d like FieldAdapter to be consistent with that design. I’m open to switching to your design if you can show evidence that it has more interesting properties (for instance I think your design has better performance since field names are computed only once, but it has to be measured!).

I will add some additional comments directly on the code.

}
}

trait Adapter extends (String => String)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I tend to avoid extending => for types populated by implicit values, because such values can act as implicit conversions.
(this behaviour should not happen here, though, because the argument and return type are the same, though)

@gcpagano
Copy link
Contributor Author
gcpagano commented Jun 9, 2016

Hi, no problem.

Yes, the main reason I've decided to use that design was to being able to compute the field names only once.

I'll try to find some time to work on the explicit configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants