In a nested json, it would be useful to be able to exit an object you have entered - a function that does the opposite of enter_object(). Or perhaps change the functionality of enter_object() so that full / relative paths are supported, for example "." would refer to the top level while ".." would refer to the previous level. Here is some code example:
library(tidyjson)
library(dplyr)
input <- '{
"name": "Bob",
"age": 30,
"social": {
"married": "yes",
"kids": "no"
},
"work": {
"title": "engineer",
"salary": 5000
}
}'
output <- input %>% as.tbl_json() %>%
spread_values(name = jstring("name"),
age = jnumber("age")) %>%
enter_object("social") %>%
spread_values(married = jstring("married"),
kids = jstring("kids")) %>%
#### I would need an exit_obeject() here
enter_object("work") %>%
spread_values(title = jstring("title"),
salary = jnumber("salary"))
In a nested json, it would be useful to be able to exit an object you have entered - a function that does the opposite of enter_object(). Or perhaps change the functionality of enter_object() so that full / relative paths are supported, for example "." would refer to the top level while ".." would refer to the previous level. Here is some code example: