flattenj {mojson} | R Documentation |
Transform multiple JSON objects into a flattened data frame.
flattenj(dat, sep = "@", compact = TRUE)
dat |
|
sep |
|
compact |
logical. Whether to generate the compact or completely expanded data frame. Defaults to |
The function flattens multiple JSON objects into a new data frame. The result contains multiple columns.
If compact=TRUE
, it returns paths
, values
and index
columns, otherwise level1
, level2
, ..., values
and index
.
The index
column stores the id of each JSON object.
data frame
. The flattened result.
library(mojson)
j <- list(a = list(x = 1, y = 2),
b = c(3, 4, list(z = 5, s = 6, t = list(m = 7, n = 8))))
j_multi <- list(j, j, j)
flattenj(j_multi)
flattenj(j_multi, compact=FALSE)