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

read_json breaks for URL sources #57

Open
luisDVA opened this issue Apr 30, 2017 · 1 comment
Open

read_json breaks for URL sources #57

luisDVA opened this issue Apr 30, 2017 · 1 comment

Comments

@luisDVA
Copy link

luisDVA commented Apr 30, 2017

read_json works perfectly fine for local json files but I cannot get it to read URL file paths, I get the error:

Error in readChar(path, nchars = file.info(path)$size) :
invalid 'nchars' argument

I suspect the function might read a patch similar to this one:
https://github.com/rstudio/profvis/blob/master/R/file_contents.R

thanks!

@colearendt
Copy link

It seems the plan is to revamp the read_json function here, as that is definitely an unhelpful error.

In any case, jsonlite::fromJSON works fine with URL sources, and that is what as.tbl_json calls behind the scenes. I.e. I recommend the following:

devtools::install_github('jeremystan/tidyjson')
library(tidyjson)

## 'http://url/to/my/json' %>% as.tbl_json()

## most verbs call as.tbl_json() behind the scenes too

"http://citibikenyc.com/stations/json" %>% json_types()
#> # A tbl_json: 1 x 2 tibble with a "JSON" attribute
#>       `attr(., "JSON")` document.id   type
#>                   <chr>       <int> <fctr>
#> 1 "{\"executionTime..."           1 object

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

No branches or pull requests

2 participants