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

Description Usage Arguments Details Value Examples

View source: R/json_types.R

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

1
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

1
2
3
4
5
6
# 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)

jeremystan/tidyjson documentation built on May 17, 2017, 6:14 p.m.