-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enter_object
: allow keeping row if object does not exist
#134
Comments
This seems to be working on my side: enter_object2 <- function (.x, ..., drop.null.json = TRUE) {
if (!tidyjson::is.tbl_json(.x))
.x <- tidyjson::as.tbl_json(.x)
path <- tidyjson:::path(...)
json <- tidyjson::json_get(.x)
json <- purrr::map(json, path %>% as.list)
tidyjson::tbl_json(.x, json, drop.null.json = drop.null.json)
} It's only a bit risky because I am now depending on the internal function |
Awesome!! Thanks for reporting this - this is definitely a confusing part of the package. #121 is where we have tracked this in the past, but you have done much more on the topic than anyone previously! Would you be interested in PRing your function change and adding some tests? I am inclined to feel |
What about |
Any progress on this issue? Also, any thoughts on implementing something similar to |
Feature request
From the documentation details about
enter_object()
:Could you give the user the option to not discard?
From the source code of
enter_object
it does not seem difficult to allow this:could it be changed to this code?
Motivation
Perhaps I am not using tidyjson idiomatically, but I would like to use the code below to extract a json array and bind it as a new column. In the example below I have a tbl json with 3 rows: in the third row the object
"associated_pgs_ids"
isnull
. Therefore I cannot take advantage of this functionget_column_char()
becausetidyjson::enter_object
will return only two rows instead of three, not allowing me to further bind this column to the starting tibble.get_column_chr()
Example code
The text was updated successfully, but these errors were encountered: