| yaml_parse | R Documentation |
yaml_parse() parses a single YAML document. yaml_parse_all() parses a
YAML stream and returns one element per document.
yaml_parse(
x,
simplify = FALSE,
aliases = c("resolve", "error"),
big_integers = c("bigint", "double", "error"),
tags = c("ignore", "error"),
duplicate_keys = FALSE,
max_depth = 128L,
max_size = 64 * 1024^2,
max_nodes = 1e+06,
path = NULL
)
yaml_parse_all(
x,
simplify = FALSE,
aliases = c("resolve", "error"),
big_integers = c("bigint", "double", "error"),
tags = c("ignore", "error"),
duplicate_keys = FALSE,
max_depth = 128L,
max_size = 64 * 1024^2,
max_nodes = 1e+06,
path = NULL
)
x |
A length-one character vector containing YAML, or a raw vector of UTF-8 YAML bytes. |
simplify |
If |
aliases |
How to treat YAML aliases. |
big_integers |
How to represent integers too large for an R numeric
type to hold exactly (beyond 2^53). |
tags |
How to treat an application tag such as |
duplicate_keys |
If |
max_depth |
Maximum nesting depth, or |
max_size |
Maximum input size in bytes, or |
max_nodes |
Maximum number of R values materialised, or |
path |
Optional file path, used only to make error messages more
informative. |
Both functions parse the input as a stream. yaml_parse() then requires it
to contain exactly one document, so trailing documents are never silently
discarded:
| documents | yaml_parse() | yaml_parse_all() |
| 0 | error | list() |
| 1 | the object | list of length 1 |
| more | error | list of that length |
A zero-document stream is an error rather than NULL, because NULL is
the legitimate result of parsing a document whose content is null.
Comment-only input is a zero-document stream.
yaml_parse() returns an R object. yaml_parse_all() returns a
list with one element per document.
yaml_parse("host: localhost\nport: 8080\ntls: true\n")
# The core schema, not YAML 1.1: `yes` is a string, and a quoted number
# stays a string.
str(yaml_parse("answer: yes\nversion: \"42\"\n"))
# A stream is not a sequence: one element per document.
yaml_parse_all("---\nfirst\n---\nsecond\n")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.