How to get a list with the Typesafe config library
For the record, since Scala 2.12 JavaConversions
are deprecated so you can:
import collection.JavaConverters._
val myList: List[String] = modifyConfig.getStringList("mylist").asScala.toList
As @ghik notes, the Typesafe Config library is Java based, so you get a java.util.List[String]
instead of a scala.List[String]
. So either you make a conversion to a scala.List
:
import collection.JavaConversions._
val myList = modifyConfig.getStringList("mylist").toList
Or (probably less awkward) you look for a Scala library. The tools wiki links at least to these maintained libraries:
- Configrity
- Bee Config
(Disclaimer: I don't use these, so you will have to check that they support your types and format)