Class YamlParser

All Implemented Interfaces:
ArrayRecordReadable, RecordReadable, YamlMetaProvider

Parses YAML text into a POJO model.
Media types

Handles Content-Type types: application/yaml, text/yaml

Description

This parser uses an indentation-aware state machine to parse YAML directly into POJOs without intermediate DOM objects. It supports block-style and flow-style mappings and sequences, plain and quoted scalars, comments, document markers, and standard YAML scalar types.

Limitations compared to JSON

The YAML parser has some limitations when compared to JsonParser:

  • Maps with non-String keys (Boolean, Date, Temporal, Enum) may not round-trip correctly when the target type is a generic Map with those key types. LinkedHashMap and TreeMap with String keys work reliably.
  • No strict vs non-strict mode; unlike JSON, there is no equivalent to JSON's lax parsing of comments, unquoted attributes, or concatenated strings.
  • YAML's indentation-based structure requires consistent formatting; malformed indentation can cause parsing errors where equivalent JSON would parse successfully.
Example input (Map of name/age):

name: Alice age: 30

Complex (nested object + array):

name: Alice age: 30 address: street: 123 Main St city: Boston state: MA tags: - a - b - c

Notes:
  • This class is thread safe and reusable.
See Also: