Open krlmlr opened 1 year ago
This is because the code path for colmajor is used when the input is a data frame. This makes the error message indeed quite confusing. Regarding the errors themselves:
json <- '[{ "a": 1, "b": [{ "c": 1, "d": 2 }, {}] }, { "a": 2, "b": [] }]'
nested_list <- tibble::as_tibble(jsonlite::fromJSON(json))
nested_list
#> # A tibble: 2 × 2
#> a b
#> <int> <list>
#> 1 1 <df [2 × 2]>
#> 2 2 <df [0 × 0]>
Created on 2023-07-07 with reprex v2.0.2
In the colmajor format (and therefore data frames) all columns are required. So, to me it kind of makes sense to error here but it is also quite confusing.
d
json <- '[{ "a": 1, "b": [{ "c": 1, "d": 2 }, {}] }, { "a": 2, "b": [{ "c": 1 }] }]'
nested_list <- tibble::as_tibble(jsonlite::fromJSON(json))
nested_list
#> # A tibble: 2 × 2
#> a b
#> <int> <list>
#> 1 1 <df [2 × 2]>
#> 2 2 <df [1 × 1]>
Created on 2023-07-07 with reprex v2.0.2
Basically the same case as before.
NULL
json <- '[{ "a": 1, "b": [{ "c": 1, "d": 2 }, {}] }, { "a": 2, "b": null }]'
nested_list <- tibble::as_tibble(jsonlite::fromJSON(json))
nested_list
#> # A tibble: 2 × 2
#> a b
#> <int> <list>
#> 1 1 <df [2 × 2]>
#> 2 2 <NULL>
Created on 2023-07-07 with reprex v2.0.2
This works because NULL
gets a special treatment as the missing value of a list.
But it is also a bit annoying that all examples work with the same spec if using simplifyDataFrame = FALSE
.
I'm seeing weird references to "colmajor" when an empty JSON array
[]
is parsed by atib_df()
. What am I doing wrong?CC @TSchiefer.
Created on 2023-04-17 with reprex v2.0.2