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

how to use ficus to load inner config #10

kretes opened this Issue Jan 5, 2015 · 3 comments


None yet
4 participants
Copy link

kretes commented Jan 5, 2015

I have an example like this:

 "load embedded config with ficus" in {
      import net.ceedubs.ficus.readers.ArbitraryTypeReader._
      import net.ceedubs.ficus.Ficus._
      val config = ConfigFactory.parseString(
        """a { value = 2 }
          |b { value = 3 }""".stripMargin)

      case class Conf(value:Int)[Conf]("a").value must_==(2)[Conf]("b").value must_==(3)

      def getConf(config:Config) : Conf = {[Conf]

      val a:Conf = getConf(config.getConfig("a"))
      val b:Conf = getConf(config.getConfig("b"))

where 'getConf' does not compile. What I want is to make 'getConf' method working as a config parser, which is given config part only, without knowing what the surrounding key was.

currently I nned to do config.asConf or else I do not get a 'Conf' instance.

is it something missing in Ficus, or am I doing something wrong?


This comment has been minimized.

Copy link

ceedubs commented Jan 5, 2015

Yeah, as of now Ficus doesn't support extracting a value without its key. At one point I tried to implement Ficus so that readers were based just on value types and not keys, but the Typesafe Config API just is not very conducive to that.

One silly workaround is to put the value at a dummy key and then extract that key. For example:

private[this] val DummyKey = "dummy-key"

def getConf(config:Config) : Conf = {



This comment has been minimized.

Copy link

artgon commented Mar 29, 2015

Created a PR that can hopefully address it -- at least the way I've been using Ficus in my app.

See: #11


This comment has been minimized.

Copy link

arkadius commented Mar 3, 2016

You can wrap your config object this way:

ConfigFactory.empty().withValue("x", config.root()).as[T]("x")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment