| cbor_validate | R Documentation |
Checks that x holds well-formed, valid CBOR within the given limits,
without building any R value. This is exactly the check cbor_decode()
runs before it builds anything, so the two agree about the bytes; they
disagree only where the bytes are valid but R cannot hold the value, such
as a text string containing U+0000.
cbor_validate(
x,
sequence = FALSE,
deterministic = FALSE,
duplicate_keys = FALSE,
max_depth = 256L,
max_size = 64 * 1024^2,
max_items = 1e+06,
error = FALSE
)
x |
A raw vector. |
sequence |
If |
deterministic |
If |
duplicate_keys |
If |
max_depth |
Deepest nesting allowed, counting arrays, maps and tags.
At most |
max_size |
Largest input allowed, in bytes, or |
max_items |
Most data items allowed, counting every tag and every
chunk of an indefinite-length string, or |
error |
If |
The check covers well-formedness (RFC 8949 section 3), UTF-8 in text
strings, the content of the tags RFC 8949, RFC 8943 and RFC 8746
restrict (their content type, the date text of tags 0 and 1004, the
length of a typed array, the shape of a multi-dimensional array),
duplicate map keys
(compared by value, so 1 encoded in one byte and in two is the same key),
and the limits.
TRUE or FALSE; with error = TRUE, TRUE invisibly or an
error.
cbor_validate(as.raw(c(0x83, 0x01, 0x02, 0x03))) # [1, 2, 3]
cbor_validate(as.raw(c(0x83, 0x01, 0x02))) # truncated
cbor_validate(as.raw(c(0xa2, 0x01, 0x00, 0x01, 0x00))) # {1: 0, 1: 0}
cbor_validate(as.raw(c(0x01, 0x02)), sequence = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.