cereal_to_json | R Documentation |
The function cereal_to_json()
serializes the
vctrs prototype
of a data frame to JSON, and the function cereal_from_json()
deserializes
from a JSON prototype back to a vctrs prototype.
cereal_to_json(data)
cereal_from_json(x)
data |
A data frame |
x |
A JSON string |
cereal_to_json()
returns a JSON string like jsonlite::toJSON()
,
and cereal_from_json()
returns a vctrs ptype, like vctrs::vec_ptype()
.
cereal_encode()
, cereal_decode()
df <- tibble::tibble(
a = 1,
b = 2L,
c = Sys.Date(),
d = as.POSIXct("2019-01-01", tz = "America/New_York"),
e = "x",
f = factor("blue", levels = c("blue", "green", "red")),
g = ordered("small", levels = c("small", "medium", "large"))
)
json <- cereal_to_json(df)
json
str(cereal_from_json(json))
## same as:
str(vctrs::vec_ptype(df))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.