# A simple character array example
json <- '["a", "b", "c"]'
# Check that this is an array
json %>% json_types
# Gather array and check types
json %>% gather_array %>% json_types
# Extract string values
json %>% gather_array %>% append_values_string
# A more complex mixed type example
json <- '["a", 1, true, null, {"name": "value"}]'
# Then we can use the column.name argument to change the name column
json %>% gather_array %>% json_types
# A nested array
json <- '[["a", "b", "c"], ["a", "d"], ["b", "c"]]'
# Extract both levels
json %>% gather_array("index.1") %>% gather_array("index.2") %>%
append_values_string
# Some JSON begins as an array
commits %>% gather_array
# We can use spread_all to capture all values
# (recursive = FALSE to limit to the top level object)
library(dplyr)
commits %>% gather_array %>% spread_all(recursive = FALSE) %>% glimpse
Run the code above in your browser using DataLab