This function will take a nested list and make it into a tibble. This can be helpful with nested lists that have varying structures and depths.
nested_list_to_tibble(.list, col_names = "col_")
.list | A list object. |
---|---|
col_names | A character. String that represents the names of the columns after the transformation |
A tibble
if (FALSE) { json <- ' { "stuff": { "buried": { "deep": [ { "location": "here", "name": "Laura DeCicco", "super_power": "fixing merge conflicts", "other_secret_power": [] }, { "location": "here", "name": "Amanda Dobbyn", "super_power": "flight", "more_nested_stuff": 4 } ], "alsodeep": 2342423234, "stilldeep": { "even_deeper": [ { "location": "not here", "name": "Jim Hester", "super_power": [] }, { "location": "here", "name": "Christine Stawitz", "super_power": "invisibility", "more_nested_stuff": 5 }, { "location": "here", "name": "Isabella Velasquez", "super_power": "teleportation" } ] } } } }' my_list <- jsonlite::fromJSON(json) data <- nested_list_to_tibble(my_list) }