tidyjson (version 0.2.4)

json_types: Add a column that tells the 'type' of the JSON data

Description

The function json_types inspects the JSON associated with each row of the tbl_json object, and adds a new column ("type" by default) that identifies the type according to the JSON standard at http://json.org/.

Usage

json_types(.x, column.name = "type")

Arguments

.x

a json string or tbl_json object

column.name

the name to specify for the type column

Value

a tbl_json object

Details

This is particularly useful for inspecting your JSON data types, and can often follows after gather_array, gather_object or enter_object to inspect the types of the elements of JSON objects or arrays.

Examples

Run this code
# NOT RUN {
# A simple example
c('{"a": 1}', '[1, 2]', '"a"', '1', 'true', 'null') %>% json_types

# Type distribution in the first 10 companies
library(dplyr)
companies[1:10] %>% gather_object %>% json_types %>% count(type)
# }

Run the code above in your browser using DataLab