unpack_json_cols.Rd
Unserialize data frame columns that contain JSON
unpack_json_cols(x, cols)
# S3 method for data.table
unpack_json_cols(x, cols)
# S3 method for data.frame
unpack_json_cols(x, cols)
a data.frame
character
vector. The names of the text columns containing
JSON strings that should be expanded.
a data.frame
with additional columns expanded from the columns
containing JSON
x <- data.frame(
name = "example data",
fields = '{"letters":["a","b","c"], "LETTERS":["A","B","C"]}',
stringsAsFactors = FALSE
)
res <- unpack_json_cols(x, "fields")
res
#> name letters LETTERS
#> 1 example data a, b, c A, B, C
res$letters[[1]]
#> [1] "a" "b" "c"