Data formats · real, tested code

Parse YAML in Larzscript

Parse a YAML document (nested mappings, lists of scalars) into real Larzscript data.

A deliberately honest subset - no anchors, no flow style, no multi-document files - covering the config-file shape YAML is actually used for most often.

larzscript pkg install yaml

Code

import "yaml" as yaml

let data = yaml.parse("name: Ada\nage: 36\ntags:\n  - dev\n  - admin\n")
print(data["name"], data["age"])
print(data["tags"])
Output
Ada 36
[dev, admin]