-
-
Notifications
You must be signed in to change notification settings - Fork 152
Open
Labels
yamlIssue related to YAML format backendIssue related to YAML format backend
Description
JsonParseException when YAML mapping key is a sequence
Description
I am trying to parse a YAML document using Jackson’s YAMLMapper (jackson-dataformat-yaml) in Kotlin/Java, but parsing fails when a mapping key is a sequence. The exception occurs before any schema validation, indicating that YamlMapper cannot handle this case.
YAML Example
? [user, 123]
: name: Иван
age: 30Kotlin Example
import com.fasterxml.jackson.dataformat.yaml.YAMLMapper
fun main() {
val yaml = """
? [user, 123]
: name: Иван
age: 30
""".trimIndent()
val mapper = YAMLMapper()
val node = mapper.readTree(yaml) // Exception occurs here
}Exception
com.fasterxml.jackson.core.JsonParseException:
Expected a field name (Scalar value in YAML), got this instead:
<org.yaml.snakeyaml.events.SequenceStartEvent(anchor=null, tag=null, implicit=true)>
Environment
- jackson-dataformat-yaml version: 2.15.x
- Kotlin/Java 17
- OS: macOS / Linux
Notes / Expected Behavior
- According to the YAML spec, using a sequence as a mapping key is valid.
- Jackson fails because
JsonNodeonly supports scalar keys. - Ideally, Jackson should either parse the key into a string representation or provide a clear API to handle non-scalar mapping keys.
References
- YAML spec: https://yaml.org/spec/1.2/spec.html#id2760799
- Jackson YAMLMapper / YAMLFactory
Request
- Support for sequence (and possibly other complex structures) as mapping keys, or
- Better documentation / error message when sequence is used as a key.
Metadata
Metadata
Assignees
Labels
yamlIssue related to YAML format backendIssue related to YAML format backend