gather_keys: Stack a JSON "key": value object

Description Usage Arguments Details Value Examples

Description

Given a JSON key value structure, like "key1": 1, "key2": 2, the gather_keys() function duplicates the rows of the tbl_json data.frame for every key, adds a new column (default name "key") to capture the key names, and then dives into the JSON values to enable further manipulation with downstream tidyjson functions.

Usage

1
gather_keys(x, column.name = "key")

Arguments

x

a tbl_json whose JSON attribute should always be an object

column.name

the name to give to the column of key names created

Details

This allows you to *enter into* the keys of the objects just like 'gather_array' let you enter elements of the array.

Value

a tbl_json with a new column (column.name) that captures the keys and JSON attribute of the associated value data

Examples

1
2
library(magrittr)  # for %>%
'{"name": "bob", "age": 32}' %>% gather_keys %>% json_types

sailthru/tidyjson documentation built on May 29, 2019, 12:59 p.m.