Skip to content
Prev 374508 / 398513 Next

help with json data from the web into data frame in R

That said, I have two issues to ask for help with:

1) how to ignore cert errors with a fromJSON call

And 

2) why the json data from the example link doesn't convert to a data frame.  As seen in the following example

library("rjson")
result <- fromJSON(file = "https://www.semantic-mediawiki.org/w/api.php?action=ask&query=[[Category:City]]|?Capital%20of|?Has%20area&format=json")
json_data_frame <- as.data.frame(result)
print(json_data_frame)

which results in:
Warning message:
package ?rjson? was built under R version 3.4.4
Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE,  : 
  arguments imply differing number of rows: 0, 1
Error in print(json_data_frame) : object 'json_data_frame' not found
-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Evans, Richard K. (GRC-H000)
Sent: Tuesday, May 08, 2018 11:52 AM
To: David Winsemius
Cc: r-help at r-project.org
Subject: Re: [R] help with json data from the web into data frame in R

Right. I'm trying to access a server within my organization which has a cert error that I cannot fix. 

The example link I provided was to a site on the web that does not have the cert error.