yaml_read: Read and write YAML files

View source: R/files.R

yaml_readR Documentation

Read and write YAML files

Description

yaml_read() reads one YAML document from a file; yaml_read_all() reads a stream. yaml_write() and yaml_write_all() are their counterparts.

Usage

yaml_read(path, ...)

yaml_read_all(path, ...)

yaml_write(x, path, ...)

yaml_write_all(x, path, ...)

Arguments

path

Path to a file.

...

Passed to yaml_parse() or yaml_emit().

x

An R object. yaml_write_all() takes a list, one element per document.

Details

These work on bytes, not text: files are read and written with readBin() and writeBin(), so nothing depends on the session's locale, and the file path is carried into parse errors to make them locatable.

Value

yaml_read() returns an R object and yaml_read_all() a list of them. The writers return path invisibly.

Examples

path <- tempfile(fileext = ".yml")
yaml_write(list(host = "localhost", port = 8080L), path)
yaml_read(path)
unlink(path)

zuyaml documentation built on Oct. 7, 2026, 5:08 p.m.