title: Converting a JSON structured url to data in R
body: <p>I am currently stuck on a problem with converting data from an API url to an actual list or data frame. I have used the same functions on different url sites and there was no issue regarding these. However, on my latest attempt something seems to be off. I have tried the following ways:</p>
  <pre><code>library(httr)
  library(jsonlite)
  url &lt;- &quot;https://cds-api.bwin.com/bettingoffer/fixtures?x-bwin-accessid=NTZiMjk3OGMtNjU5Mi00NjA5LWI2MWItZmU4MDRhN2QxZmEz&amp;lang=en&amp;country=NL&amp;offerMapping=Filtered&amp;offerCategories=Gridable&amp;sportIds=4&amp;sortBy=Tags&quot;
  
  r &lt;- GET(url)
  raw_data_bwin &lt;- fromJSON(content(r, &quot;text&quot;), simplifyVector = FALSE)
  </code></pre>
  <p>and</p>
  <pre><code>url &lt;- &quot;https://cds-api.bwin.com/bettingoffer/fixtures?x-bwin-accessid=NTZiMjk3OGMtNjU5Mi00NjA5LWI2MWItZmU4MDRhN2QxZmEz&amp;lang=en&amp;country=NL&amp;offerMapping=Filtered&amp;offerCategories=Gridable&amp;sportIds=4&amp;sortBy=Tags&quot;
  
  js &lt;- url %&gt;% 
    read_html() %&gt;%
    html_text() 
  
  js &lt;- fromJSON(gsub(&quot;bettingoffer/fixtures?x-bwin-accessid=NTZiMjk3OGMtNjU5Mi00NjA5LWI2MWItZmU4MDRhN2QxZmEz&amp;lang=en&amp;country=NL&amp;offerMapping=Filtered&amp;offerCategories=Gridable&amp;sportIds=4&amp;sortBy=Tags&quot;, &quot;&quot;, js))
  </code></pre>
  <p>The first piece of code gives the following error:</p>
  <pre><code>Error: lexical error: invalid char in json text.
  
  &lt;!DOCTYPE html&gt; &lt;html lang=&quot;en
  
  (right here) ------^
  </code></pre>
  <p>and the second one gives this error:</p>
  <pre><code>Error: parse error: premature EOF
  
  {&quot;fixtures&quot;:[{&quot;games&quot;:[],&quot;parti
  
  (right here) ------^
  </code></pre>
  <p>I am trying to understand more about getting data from API's and JSON structured data sets, but with my limited knowledge I cannot find a solution to this problem. Could anyone assist me with these errors?</p>