| read_toml {blogdown} | R Documentation |
Read and write TOML data (Tom's Obvious Markup Language)
Description
The function read_toml() reads TOML data from a file or a character
vector, and the function write_toml() converts an R object to TOML.
Usage
read_toml(file, x = read_utf8(file), strict = TRUE)
write_toml(x, output = NULL)
toml2yaml(file, output = NULL)
yaml2toml(file, output = NULL)
Arguments
file |
Path to an input (TOML or YAML) file. |
x |
For |
strict |
Whether to try RcppTOML and Hugo only (i.e., not to use
the naive parser). If |
output |
Path to an output file. If |
Details
For read_toml(), it first tries to use the R package RcppTOML to
read the TOML data. If RcppTOML is not available, it uses Hugo to
convert the TOML data to YAML, and reads the YAML data via the R package
yaml. If Hugo is not available, it falls back to a naive parser, which
is only able to parse top-level fields in the TOML data, and it only supports
character, logical, and numeric (including integer) scalars.
For write_toml(), it converts an R object to YAML via the R package
yaml, and uses Hugo to convert the YAML data to TOML.
Value
For read_toml(), an R object. For write_toml(),
toml2yaml(), and yaml2toml(), a character vector (marked by
xfun::raw_string()) of the TOML/YAML data if output =
NULL, otherwise the TOML/YAML data is written to the output file.
Examples
## Not run:
v = blogdown::read_toml(x = c("a = 1", "b = true", "c = \"Hello\"", "d = [1, 2]"))
v
blogdown::write_toml(v)
## End(Not run)