0

I am using R with jsonlite to get data back from a url. It's pretty straightforward except that when I view the URL in a browser, there are 50 results. But when I view my results from jsonlite there are only 25 results in my data set. I have checked the jsonlite documentation and I can't find any parameters that would indicate paging or limits of any kind. Has anyone seen this before? The code I'm using is pretty straightforward, but I'm including it anyways. I've already checked the data in between the flatten step and the fromJSON command only returns 25 rows.

library(jsonlite)
url="https://myjson"
mydata = fromJSON(url)
mydata = flatten(mydata$mydataframe,recursive=TRUE)
Unknown Coder
  • 6,625
  • 20
  • 79
  • 129
  • 1
    is it possible that the JSON you're loading isn't valid? have you tried saving the link to a local file and/or using a textConnection (i.e. `fromJSON(textConnection(" [JSON text goes here] "))` ) to try and debug the issue? – Jthorpe Mar 01 '15 at 03:14
  • Can you show the actual json data? – Jeroen Ooms Mar 01 '15 at 06:04
  • @Jthorpe & Jeroen thanks for the help. I should have mentioned that the JSON data is from a widely-available, reputable source. So I don't think it's the data feed itself. But let's go ahead and say that I'm working with this data: https://api.twitch.tv/kraken/streams – Unknown Coder Mar 01 '15 at 14:37
  • Without your actual data, it's hard to help. I recommend reading the code for flatten, and stepping through it yourself. The problem will likely be easy to spot and it's a good exercise too. – Jthorpe Mar 01 '15 at 17:56
  • @Jthorpe I posted the link above. Also, as stated earlier, the flattening is not the issue. As soon as I run the fromJason step the data set is already truncated – Unknown Coder Mar 01 '15 at 18:32
  • So the streams element in the JSON file you linked to has 25 elements, which is why there are 25 rows in the data.frame 'mydata$streams`, why were you expecting 50? – Jthorpe Mar 01 '15 at 20:55

0 Answers0