Skip to content

Fix #589: support non-scalar YAML mapping keys - #715

Open
arimu1 wants to merge 2 commits into
FasterXML:3.xfrom
arimu1:fix/yaml-sequence-mapping-key-589
Open

Fix #589: support non-scalar YAML mapping keys#715
arimu1 wants to merge 2 commits into
FasterXML:3.xfrom
arimu1:fix/yaml-sequence-mapping-key-589

Conversation

@arimu1

@arimu1 arimu1 commented Aug 15, 2026

Copy link
Copy Markdown

Fixes #589

Summary

  • Handle YAML explicit complex mapping keys (? [...] / ? {...}) in YAMLParser when SnakeYAML emits SequenceStart or MappingStart where a property name is expected
  • Consume the full key structure and expose it as a flow-style string property name (e.g. [user, 123], {foo: bar}) so YAMLMapper / readTree() can parse documents that use sequence or mapping keys per the YAML spec
  • Support Alias references and skip Comment events while decoding complex keys; validate nesting depth against current parser context; preserve deferred object anchor on first complex key entry
  • Add streaming parser and readTree tests for sequence/mapping complex keys, implicit flow keys, nested/empty keys, quoted specials, and alias-in-key

Test plan

  • mvn -pl yaml -Dtest=StreamingYAMLParseTest#testComplexMappingKey* (9 tests, 0 failures; Java 17)
  • StreamingYAMLParseTest#testComplexMappingKeySequence — reproduces issue example ? [user, 123]: ...
  • StreamingYAMLParseTest#testComplexMappingKeyMapping — mapping-as-key case with readTree
  • Additional cases: implicit flow key, nested complex key, empty []/{}, quoted specials, alias-in-key, object anchor deferral on first entry

When SnakeYAML emits SequenceStart or MappingStart for an explicit complex
key (? [...] or ? {...}), consume the key structure and expose it as a
flow-style string property name so YAMLMapper/readTree can parse the document.
@arimu1
arimu1 force-pushed the fix/yaml-sequence-mapping-key-589 branch from 7d2c2dc to 57bdcce Compare August 15, 2026 03:00
Handle Alias and Comment events inside complex key decoding, validate
nesting depth against parser context, preserve deferred object anchor on
first complex key entry, and expand streaming/readTree test coverage.
@arimu1
arimu1 force-pushed the fix/yaml-sequence-mapping-key-589 branch from 33a812b to d1f8bd4 Compare August 15, 2026 03:05
@github-actions

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 78.91% 📈 +0.120%
Branches branches 72.71% 📈 +0.050%

Coverage data generated from JaCoCo test results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JsonParseException when YAML mapping key is a sequence

1 participant