I have a HOCON config like this:
[
{
name = 1
url = "http://example.com"
},
{
name = 2
url = "http://example2.com"
},
{
name = 3
url = {
A = "http://example3.com"
B = "http://example4.com"
}
}
]
I want to parse it with pureconfig. How can I represent that the URL can be either a string or a map of multiple urls, each having a key?
I have tried this:
import pureconfig.ConfigSource
import pureconfig.generic.auto.exportReader
case class Site(name: Int, url: Either[String, Map[String, String]])
case class Config(sites: List[Site])
ConfigSource.default.loadOrThrow[Config]
But it resulted in "Expected type OBJECT. Found STRING instead."
I know pureconfig supports Option
. I have found no mention of supporting Either
, does it mean it can be replaced with something else?