Native Delphi YAML/KYAML DOM, parser, and flow-style writer.
XENOME.YAML.pas provides one central object model for both Kubernetes KYAML and practical YAML input:
yeKYAMLparses the safer Kubernetes KYAML flow-style subset.yeYAMLparses common YAML block/flow syntax into the same DOM.- The writer emits KYAML-compatible flow-style output in readable or condensed mode.
- No external C libraries, DLL wrappers, or runtime parser dependencies are used.
Main classes:
TYAMLTYAMLValueTYAMLNullTYAMLStringTYAMLIntegerTYAMLFloatTYAMLBooleanTYAMLObjectTYAMLArray
Factory entry points:
Y := TYAML.NewObjectRoot;
Y := TYAML.NewArrayRoot;
Y := TYAML.FromString(Text, yeYAML);
Y := TYAML.FromFile(FileName, yeKYAML);
Y := TYAML.FromStream(Stream, yeYAML);Object and array builders:
Root := Y.AsObject;
Root.Add('apiVersion', 'v1');
Root.SetOrAdd('kind', 'Pod');
Metadata := Root.GetOrAddObject('metadata');
Containers := Root.GetOrAddObject('spec').GetOrAddArray('containers');
Container := Containers.AddObject;
Container.Add('name', 'nginx');Root and document access:
Y.Root;
Y.IsObject;
Y.AsObject;
Y.ObjectValue['kind'];
Y.ArrayValue[0];
Y.DocumentCount;
Y.DocumentAsObject(1);yeKYAML intentionally rejects generic YAML features that Kubernetes KYAML excludes:
- indentation-sensitive block mappings
- unquoted string values
- anchors and aliases
- YAML tags
- merge keys
- block scalars
- complex mapping keys
Example:
Y := TYAML.FromString(
'--- {apiVersion: "v1", kind: "Pod", spec: {containers: [{name: "nginx"}]}}',
yeKYAML);yeYAML accepts common YAML documents and streams while preserving the same DOM API used by KYAML. Supported areas include block mappings, sequences, flow collections, quoted/plain scalars, numeric/boolean/null scalars, anchors, aliases, merge keys, tags as ignored node properties, block scalars, and multi-document streams.
The DOM is intentionally JSON/KYAML-shaped, so YAML features without a natural DOM representation are normalized. For example, complex keys are converted to string keys.
The writer emits KYAML-compatible flow syntax:
Text := Y.WriteToString(ywmReadable);
Text := Y.WriteToString(ywmCondensed);
Y.WriteDocumentMarker := True;String values are always double-quoted. Object keys are emitted plain when safe and quoted otherwise.