mgirlich/jsontools

handling of NA and null in `json_unnest_longer/wider()`

Opened this issue · 0 comments

in json_flatten() it makes sense to drop NA, json nulls, empty arrays and nulls in arrays as one cannot know where they came from -> they are useless.

  • should NA, json nulls, empty arrays and nulls in arrays all be treated the same?
  • sometimes it might make sense to keep them
  • tidyr::unnest_longer() keeps them
tidyr::unnest_longer(
  tibble::tibble(
    id = 1:2,
    l = list(NULL, c(3, 5, 9))
  ),
  l
)
#> # A tibble: 4 x 2
#>      id     l
#>   <int> <dbl>
#> 1     1    NA
#> 2     2     3
#> 3     2     5
#> 4     2     9
  • add argument how to handle?