json_lengths | R Documentation |
When investigating JSON data it can be helpful to identify the lengths of the
JSON objects or arrays, especialy when they are 'ragged' across documents.
The json_lengths
function adds a column (default name "length"
)
that contains the 'length' of the JSON associated with each row. For objects,
this will be equal to the number of name-value pairs. For arrays, this will
be equal to the length of the array. All scalar values will be of length 1,
and null will have length 0.
json_lengths(.x, column.name = "length")
.x |
a json string or |
column.name |
the name to specify for the length column |
a tbl_json
object
json_complexity
to compute the recursive length of
each value
# A simple example json <- c('[1, 2, 3]', '{"k1": 1, "k2": 2}', '1', 'null') # Complexity is larger than length for nested objects json %>% json_lengths # Worldbank objcts are either length 7 or 8 library(magrittr) worldbank %>% json_lengths %$% table(length) # All commits are length 8 commits %>% gather_array %>% json_lengths %$% table(length)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.