【发布时间】:2021-08-28 15:22:30
【问题描述】:
假设我有以下配置:
{
“default-value”:5,
“some-seq”: [
{“some-other-value”:100},
{“foo”:”bar”},
{“some-other-value”:1500}
]
}
我希望将其解码为案例类:
case class Config(defaultValue: Int, someSeq: Seq[SomeInteger])
case class SomeInteger(someOtherValue: Int)
这样它就会创建 Config(5, Seq(SomeInteger(100), SomeInteger(5), SomeInteger(1500))) (第二个是 5,因为列表的第二个对象中没有其他值键) 有办法吗?
【问题讨论】:
-
那是什么配置?看起来不像 HOCON
-
抱歉,忘记在配置中的变量名和尾随逗号周围添加引号。写得非常快,现在编辑成看起来像一个普通的 application.conf 文件。是HOCON ????
-
抱歉,已在说明中修复
标签: scala pureconfig