enter_object: Dive into a specific object "key"

Description Usage Arguments Details Examples

Description

JSON can contain nested objects, such as "key1": "key2": [1, 2, 3]. The function enter_object() can be used to access the array nested under "key1" and "key2". After using enter_object(), all further tidyjson calls happen inside the referenced object (all other JSON data outside the object is discarded). If the object doesn't exist for a given row / index, then that data.frame row will be discarded.

Usage

1

Arguments

x

a tbl_json object

...

path to filter

Details

This is useful when you want to limit your data to just information found in a specific key. Use the ... to specific a sequence of keys that you want to enter into. Keep in mind that any rows with JSON that do not contain the key will be discarded by this function.

Examples

1
2
3
4
5
6
library(magrittr)  # for %>%
c('{"name": "bob", "children": ["sally", "george"]}', '{"name": "anne"}') %>%
  spread_values(parent.name = jstring("name")) %>%
  enter_object("children") %>%
  gather_array %>%
  append_values_string("children")

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