0

When running the following call on Mac I get an error as follows

jsonlite::fromJSON(url(paste("https://fantasy.premierleague.com/api/element-summary/236")))

Error in parse_con(txt, bigint_as_char) : parse error: premature EOF

                     (right here) ------^

However the following call works correctly, with the only difference being the omission of the url().

jsonlite::fromJSON(paste("https://fantasy.premierleague.com/api/element-summary/236"))

The traceback from the error is as follows:

4: parse_con(txt, bigint_as_char)
3: parseJSON(txt, bigint_as_char)
2: parse_and_simplify(txt = txt, simplifyVector = simplifyVector, 
       simplifyDataFrame = simplifyDataFrame, simplifyMatrix = simplifyMatrix, 
       flatten = flatten, ...)
1: jsonlite::fromJSON(url(paste("https://fantasy.premierleague.com/api/element-summary/236")))

I've tried on two separate installations with the same result. I wonder if the line break after the first line of the JSON is being interpreted as EOF....

MarkMan
  • 184
  • 6
  • 1
    Actually, I ran those two commands on my mac. And they both worked well (with and without url() ). I haven't got an error. But [this question](https://stackoverflow.com/questions/42909047/importing-data-from-json-file-to-r?rq=1) or [this one](https://stackoverflow.com/questions/43302834/is-there-a-way-other-than-below-to-load-a-json-rows-file-into-rstudio) may be helpful. – maydin Jul 16 '19 at 20:43
  • Interesting - I've tried on 3 different Macs all with a Fresh install of R. Can you say what version of R you are running? – MarkMan Jul 19 '19 at 06:59
  • `R version 3.5.1 (2018-07-02)` and `platform : x86_64-apple-darwin15.6.0 ` . Here is a [link](https://pasteboard.co/IoFjVj8.png) of the output of the code with url(). – maydin Jul 19 '19 at 07:24

0 Answers0