spread_values: Create new columns with JSON values

Description Usage Arguments Examples

Description

The spread_values() function lets you dive into (potentially nested) JSON objects and extract specific values. spread_values() takes jstring(), jnumber() or jlogical() named function calls as arguments in order to specify the type of the data that should be captured at each desired key location. These values can be of varying types at varying depths.

Usage

1

Arguments

x

tbl_json object

...

column=value list where 'column' will be the column name created and 'value' must be a call to jstring(), jnumber() or jlogical() specifying the path to get the value (and the type implicit in the function name)

Examples

1
2
3
4
5
6
library(magrittr)  # for %>%
'{"name": {"first": "bob", "last": "jones"}, "age": 32}' %>%
  spread_values(
    first.name = jstring("name", "first"),
    age = jnumber("age")
  )

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