Link Search Menu Expand Document

Maps can be serialized with String keys

val config =
    ConfigFactory.parseString(
        """
|map {  
|  foo = 5
|  bar = 6
|}"""
            .trimMargin(),
    )
val map: Map<String, Int> = config.extract("map")
println(map["foo"] == 5) // true
println(map["bar"] == 6) // true

or with arbitrary keys

val config =
    ConfigFactory.parseString(
        """
|map = [{  
|  key = 5
|  value = "foo"
|}
|{
|  key = 6
|  value = "bar"
|}]"""
            .trimMargin(),
    )
val map: Map<Int, String> = config.extract("map")
println(map[5] == "foo") // true
println(map[6] == "bar") // true


Copyright © 2016-2021 morihiro, since 2021 The Config4k Team. Distributed by an Apache License 2.0.