json_structure {tidyjson}R Documentation

Recursively structures arbitrary JSON data into a single data frame

Description

Returns a tbl_json object where each row corresponds to a leaf in the JSON structure. The first row corresponds to the JSON document as a whole. If the document is a scalar value (JSON string, number, logical or null), then there will only be 1 row. If instead it is an object or an array, then subsequent rows will recursively correspond to the elements (and their children) of the object or array.

Usage

json_structure(.x)

Arguments

.x

a json string or tbl_json object

Details

The columns in the tbl_json returend are defined as

Value

a tbl_json object

See Also

json_schema to create a schema for a JSON document or collection

Examples


# A simple string
'"string"' %>% json_structure

# A simple object
'{"name": "value"}' %>% json_structure

# A complex array
'[{"a": 1}, [1, 2], "a", 1, true, null]' %>% json_structure

# A sample of structure rows from a company
library(dplyr)
companies[1] %>% json_structure %>% sample_n(5)

[Package tidyjson version 0.3.2 Index]