tidyjson (version 0.2.2)

spread_values: Create new columns with JSON values

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

spread_values(x, ...)

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

Run this code
library(magrittr)  # for %>%
'{"name": {"first": "bob", "last": "jones"}, "age": 32}' %>%
  spread_values(
    first.name = jstring("name", "first"),
    age = jnumber("age")
  )

Run the code above in your browser using DataLab