Him188 / yamlkt

Multiplatform YAML parser & serializer for kotlinx.serialization written in pure Kotlin
Apache License 2.0
132 stars 14 forks source link

yaml deserialization content starting with '---' #32

Open HoffiMuc opened 3 years ago

HoffiMuc commented 3 years ago

if yaml starts with '---', e.g.:

---
USING_DNSMASQ_ON_HOST: true
DEPLOY_LOCALPATHSTORAGE: true
        val yamlConf = Yaml.decodeFromString(YamlConf.serializer(), File("conf.yml").readText())

result:

Exception in thread "main" net.mamoe.yamlkt.YamlDecodingException: Top-level decoder: illegal beginning token MULTILINE_LIST_FLAG on decoding class
---
^ at line 1, column 2

without the '---', line it works fine.

Him188 commented 3 years ago

As a temporary workaround, please do removePrefix("---") before calling decodeFromString.