tidyjson (version 0.2.2)

append_values: Appends all values with a specified type as a new column

Description

The append_values_X functions let you take any remaining JSON and add it as a column X (for X in "string", "number", "logical") insofar as it is of the JSON type specified.

Usage

append_values_string(x, column.name = type, force = TRUE)

append_values_number(x, column.name = type, force = TRUE)

append_values_logical(x, column.name = type, force = TRUE)

Arguments

x
a tbl_json object
column.name
the column.name to append the values into the data.frame under
force
parameter that determines if the variable type should be computed or not if force is FALSE, then the function may take more memory

Details

Any values that do not conform to the type specified will be NA in the resulting column. This includes other scalar types (e.g., numbers or logicals if you are using append_values_string) and *also* any rows where the JSON is still an object or an array.

Examples

Run this code
library(magrittr)  # for %>%
'{"first": "bob", "last": "jones"}' %>%
  gather_keys() %>%
  append_values_string()

Run the code above in your browser using DataLab