Json lines é um arquivo em que cada linha é um json
https://jsonlines.org/examples/
Pesquisei rapidamente na internet e não achei nada pronto.
Uma forma que pensei em fazer a leitura:
jsonl <- '{"name": "Gilbert", "wins": [["straight", "7♣"], ["one pair", "10♥"]]}
{"name": "Alexa", "wins": [["two pair", "4♠"], ["two pair", "9♠"]]}
{"name": "May", "wins": []}
{"name": "Deloise", "wins": [["three of a kind", "5♣"]]}'
linhas <- vroom::vroom_lines(jsonl)
purrr::map(
linhas,
jsonlite::fromJSON,
simplifyVector = TRUE,
simplifyMatrix = FALSE,
simplifyDataFrame = TRUE
) |>
# bind_rows() ou purrr::map_dfr() não funcionam bem
data.table::rbindlist() |>
tibble::as_tibble()
#> Warning in data.table::rbindlist(purrr::map(linhas, jsonlite::fromJSON, : Column
#> 2 ['wins'] of item 3 is length 0. This (and 0 others like it) has been filled
#> with NA (NULL for list columns) to make each item uniform.
#> # A tibble: 6 x 2
#> name wins
#> <chr> <list>
#> 1 Gilbert <chr [2]>
#> 2 Gilbert <chr [2]>
#> 3 Alexa <chr [2]>
#> 4 Alexa <chr [2]>
#> 5 May <NULL>
#> 6 Deloise <chr [2]>
Created on 2021-07-27 by the reprex package (v2.0.0)
No entanto, além de gerar um warning essa forma talvez não seja muito segura e é potencialmente lenta. Dicas?