Created
January 6, 2017 09:17
-
-
Save andyscott/d29f7d36fd6e58d499e03f963ea94e22 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.typesafe.config.Config | |
import classy.core.Decoder | |
import classy.generic.derive._ | |
import classy.config._ | |
case class Bar(value: String) | |
case class Foo( | |
a: String, | |
b: Option[Int], | |
c: List[String], | |
bars: List[Bar] | |
) | |
val decoder: Decoder[String, Foo] = | |
MkDecoder[Config, Foo] | |
.renameFields(_.toUpperCase) | |
.decoder.fromString | |
val res = decoder.decode(""" | |
A = OKAY | |
B = 1235 | |
C = [ZZZ] | |
BARS = [{ VALUE: hi }] | |
""") | |
// res: Right(Foo(OKAY,Some(1235),List(ZZZ),List(Bar(hi)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment