unpack_json_cols: Unserialize data frame columns that contain JSON

View source: R/SerializerJson.R

unpack_json_colsR Documentation

Unserialize data frame columns that contain JSON

Description

Unserialize data frame columns that contain JSON

Usage

unpack_json_cols(x, cols)

## S3 method for class 'data.table'
unpack_json_cols(x, cols)

## S3 method for class 'data.frame'
unpack_json_cols(x, cols)

Arguments

x

a data.frame

cols

character vector. The names of the text columns containing JSON strings that should be expanded.

Value

a data.frame with additional columns expanded from the columns containing JSON

Examples

x <- data.frame(
  name = "example data",
  fields = '{"letters":["a","b","c"], "LETTERS":["A","B","C"]}',
  stringsAsFactors = FALSE
)
res <- unpack_json_cols(x, "fields")
res
res$letters[[1]]

s-fleck/lgr.app documentation built on Jan. 12, 2023, 8:03 p.m.