json_types {tidyjson}R Documentation

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

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.

Value

a tbl_json object

Examples


# 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)

[Package tidyjson version 0.3.2 Index]