Skip to content
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

Should import_list() work for JSON files? #199

Closed
nathancday opened this issue Feb 3, 2019 · 4 comments
Closed

Should import_list() work for JSON files? #199

nathancday opened this issue Feb 3, 2019 · 4 comments

Comments

@nathancday
Copy link
Contributor

This seems like a bug to me. The docs for ?import_list say the return value should be a list, "If rbind=FALSE (the default), a list of a data frames. "

Here is a smol reprex.

list_obj <- split(iris, iris$Species)

str(list_obj, 1)
#> List of 3
#>  $ setosa    :'data.frame':  50 obs. of  5 variables:
#>  $ versicolor:'data.frame':  50 obs. of  5 variables:
#>  $ virginica :'data.frame':  50 obs. of  5 variables:

jsonlite::write_json(list_obj,"tst.json")

str(rio::import_list("tst.json"), 1)
#> List of 1
#>  $ :'data.frame':    5 obs. of  3 variables:

str(jsonlite::read_json("tst.json"), 1)
#> List of 3
#>  $ setosa    :List of 50
#>  $ versicolor:List of 50
#>  $ virginica :List of 50

Created on 2019-02-03 by the reprex package (v0.2.1)

In building this out I found that rio::export(list_obj, "tst2.json") raises an error and think that may be related. The docs for export say "An exception to this is that x can be a list of data frames if the output file format is an Excel .xlsx workbook, .Rdata file, or HTML file. See examples.)" and my feeling is that JSON files should be included in these exceptions.

@nathancday nathancday changed the title Should import_list() for JSON files? Should import_list() work for JSON files? Feb 3, 2019
@leeper
Copy link
Contributor

leeper commented Feb 4, 2019

It's not a bug, it's just not supported for JSON.

@nathancday
Copy link
Contributor Author

nathancday commented Feb 4, 2019 via email

@leeper
Copy link
Contributor

leeper commented Feb 4, 2019

Definitely.

@nathancday
Copy link
Contributor Author

I'm on it!

Thanks for this package, it is key piece of file IO in the boxR package, which is how I stumbled upon it. Happy to do my part to support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants