Scala: Write value to typesafe config object

goo picture goo · Jun 11, 2014 · Viewed 22k times · Source

I'm using Typesafe config & have a config file in my resources directory which looks like this:

something {
  another {
    someconfig=abc
    anotherconfig=123
  }
}

How would I change the value of anotherconfig using scala?

Answer

Christian picture Christian · Jun 11, 2014

If you want to change the loaded config (i.e. create a new config based on the old one), you can use withValue:

val newConfig = oldConfig.withValue("something.another.anotherconfig",
  ConfigValueFactory.fromAnyRef(456))