You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When having both foo-bar and foo present in a case class, Ficus attempts to parse the value of foo-bar and assign it to foo. When they both have different types this results in a ClassCastException, however when the types are the same, ficus will assign the value of foo-bar to both foo and foo-bar.
Example that fails with ClassCastException.
import net.ceedubs.ficus.Ficus._
import net.ceedubs.ficus.readers.ArbitraryTypeReader._
import com.typesafe.config._
case class TestSettings(val `foo-bar`: Long, `foo`: String)
val config = ConfigFactory.parseString("""{ foo-bar: 3, foo: "4" }""")
val settings = config.as[TestSettings] // throws java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String!
Example that doesn't fail, but assigns the value of foo-bar to foo.
case class TestSettings2(val `foo-bar`: String, `foo`: String)
val config = ConfigFactory.parseString("""{ foo-bar: "foo-bar", foo: "foo" }""")
val settings = config.as[TestSettings2]
println(settings.`foo-bar`) // prints out foo-bar
println(settings.foo) // also prints out foo-bar!
The text was updated successfully, but these errors were encountered:
When having both
foo-bar
andfoo
present in a case class, Ficus attempts to parse the value offoo-bar
and assign it tofoo
. When they both have different types this results in a ClassCastException, however when the types are the same, ficus will assign the value offoo-bar
to bothfoo
andfoo-bar
.Example that fails with ClassCastException.
Example that doesn't fail, but assigns the value of
foo-bar
tofoo
.The text was updated successfully, but these errors were encountered: