Description Usage Arguments Examples
parse json
1 |
json |
(character) Input json string |
... |
Addtn inputs to fromJSON |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | library("httr")
library("data.table")
# GBIF example
json <- content(GET('http://api.gbif.org/v0.9/occurrence/search?taxonKey=3119195'), as = "text")
json %>%
jq %s%
'results' %v%
c('scientificName','country') %>%
rbindlist
# PLOS example
## The jqr way
json <- content(GET('http://api.plos.org/search/?q=*:*&wt=json'), as = "text")
json %>%
jq %s%
'response.docs' %v%
c('id','journal') %>%
rbindlist
## How it would be otherwise
library("jsonlite")
res <- fromJSON(json, FALSE)
out <- res$response$docs
out2 <- lapply(out, function(x) x[c('id','journal')])
rbindlist(out2)
## Thought the jqr way is a tiny bit longer, it's much more intuitive
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.