Skip to content

Problems handling :: for string without quote #66

@MarcinMoskala

Description

@MarcinMoskala

This code demonstrates the problem:

@Serializable
class HeaderConfig(
    val deckName: String,
    val articleFileName: String? = null,
    val packageDestination: String? = null,
)
val headerContent = """
    deckName: Aktywne::Zasady
    articleFileName: this/is/some/file.md
""".trimIndent()

suspend fun main() = coroutineScope<Unit> {
    val yaml by lazy {
        Yaml {
            encodeDefaultValues = false
            stringSerialization = YamlBuilder.StringSerialization.DOUBLE_QUOTATION
        }
    }
    val headerConfig = yaml.decodeFromString(HeaderConfig.serializer(), headerContent)
    println(headerConfig.deckName) // Aktywne
    println(headerConfig.articleFileName) // null
}

The result is:

Aktywne
null

Where it should be:

Aktywne::Zasady
this/is/some/file.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions