Reputation: 3177
In my Scala application I have a configuration like this:
datasets {
dataset1 = "path1"
dataset2 = "path2"
dataset3 = "path3"
}
Ho do I iterate over all the datasets to get a map [dataset, path]?
Upvotes: 3
Views: 3447
Reputation: 69
You can try my scala wrapper https://github.com/andr83/scalaconfig - it supports reading native scala types directly from config object:
val datasets = config.as[Map[String, String]]("datasets")
Upvotes: 0
Reputation: 473
You can call entrySet()
after getting config with getConfig()
import scala.collection.JavaConversions._
val config = ConfigFactory.load()
val datasets = config.getConfig("datasets")
val configMap = datasets.entrySet().toList.map(
entry => (entry.getKey, entry.getValue)
).toMap
You will end up with a Map[String, ConfigValue]
.
Upvotes: 4