【发布时间】:2019-12-27 09:18:10
【问题描述】:
我正在尝试在 this tutorial 之后使用 SnakeYAML 解析 Kotlin 中的 yaml:
data class Case(val args: List<String>, val expected: String, val score: Int)
data class TestCases(val target: String, val cases: List<Case>)
val yaml = Yaml(Constructor(TestCases::class.java))
但代码在 IntelliJ 中返回这些错误
无法访问'
':它是public/*package*/ in 'Constructor'
用于使用Constructor,如java.lang.reflect.Constructor,以及
以下函数都不能使用提供的参数调用:
- 在 org.yaml.snakeyaml.Yaml 中定义的公共构造函数 Yaml(dumperOptions: DumperOptions!)
- 在 org.yaml.snakeyaml.Yaml 中定义的公共构造函数 Yaml(loadingConfig: LoaderOptions!)
- 在 org.yaml.snakeyaml.Yaml 中定义的公共构造函数 Yaml(constructor: BaseConstructor!)
- 在 org.yaml.snakeyaml.Yaml 中定义的公共构造函数 Yaml(representer: Representer!)
使用Yaml 就像在org.yaml.snakeyaml.Yaml 中一样,我认为这是期待来自Constructor 的BaseConstructor。
我该如何解决这个问题?谢谢。
【问题讨论】:
标签: kotlin reflection yaml