Questions tagged [jsonlite]

A smarter JSON encoder and decoder

This package is a fork of RJSONIO by Duncan Temple Lang and builds on the same parser, but uses a different mapping between R objects and JSON data. More details can be found at http://cran.r-project.org/web/packages/jsonlite/index.html

A fast JSON parser and generator optimized for statistical data and the web. Started out as a fork of RJSONIO, but has been completely rewritten in recent versions. The package offers flexible, robust, high performance tools for working with JSON in R and is particularly powerful for building pipelines and interacting with web APIs.

The implementation is based on the mapping described in the vignette of the package (Ooms, 2014). In addition to drop-in replacements for toJSON and fromJSON, jsonlite contains functions to stream, validate, and prettify JSON data.

Reference manual: jsonlite.pdf Vignettes:

509 questions
0
votes
0 answers

R - jsonlite - stream_in will not accept nullValue as an argument

I'm attempting to read in data from a .json file using jsonlite, and replace all NULL values with NA. I'm using this code: business <- stream_in(file("data/yelp_academic_dataset_business.json"), nullValue = NA) And get this error opening…
Chris
  • 313
  • 1
  • 11
0
votes
2 answers

R: Using dplyr to link 2 objects (Github stats API example)

This is the structure of the github stats api data for a repository. I am using dplyr and tidy_json libraries to list the number of commits ("c") ,deletes("d"), lines of code added("a") and the corresponding week("w") for every user in a…
mongofresher
  • 173
  • 1
  • 4
  • 10
0
votes
1 answer

Format of date from a certain JSON and convert in R?

What format is the date below and how can I convert it? theData <- fromJSON(theUrl) theData["sampleDate"] $sampleDate [1] 1.439165e+12 Looking at the data in a browser, sampleDate has the value 1439164800000. Using jsonlite (and kind of new to alot…
Selman
  • 1
  • 1
  • 3
0
votes
1 answer

R JSONlite: How to extract below output?

See the below R code, I'm using JSONlite package to scrape data from a website: >url <- "http://fantasy.premierleague.com/web/api/elements/" >a<-fromJSON(paste0(url, 1)) >a Gives me following output: $id [1] 1 $photo [1]…
Manasvi Bali
  • 25
  • 1
  • 3
0
votes
1 answer

how to create json from hash in r

am new to R and have already passed at least a day trying to figure this out. I've been trying to create json from a data.table, where I'd like to use the value of one of the variables as a key, and as its value a list combining the other variables.…
lstilo
  • 5
  • 1
  • 4
0
votes
1 answer

Constructing request payload in R using rjson/jsonlite

My current code as seen below attempts to construct a request payload (body), but isn't giving me the desired result. library(df2json) library(rjson) y = rjson::fromJSON((df2json::df2json(dataframe))) globalparam = "" req = list( Inputs = list( …
Ritika R
  • 77
  • 1
  • 1
  • 9
0
votes
2 answers

Removing a string using regular expression with stringr

I am trying to get rid of the term union in the following json using str_replace_all function. I tried few regular expressions but they didn't work. Any suggestions on how to get rid of the full string of "union". Here is the code. …
user3570187
  • 1,743
  • 3
  • 17
  • 34
0
votes
0 answers

combining many data frames with rbind and pages

I am trying to rbind pages sequentially by combining the data frames using the pages. library(jsonlite) pages <- list() for(i in 1:3){ mydata<- data.frame(c(1,2), c(4,5)) pages[[i+1]] <- mydata$filings } filings <- rbind.pages(pages) When i view…
user3570187
  • 1,743
  • 3
  • 17
  • 34
0
votes
0 answers

R and jsonlite - truncated result set?

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…
Unknown Coder
  • 6,625
  • 20
  • 79
  • 129
0
votes
1 answer

apply function jsonlite R

I have a simple data.frame df a b c d 1 5 A E 2 4 B F 3 3 C G 4 2 D H 5 1 E J Let's say I want to write it in JSON…
Carlos
  • 371
  • 5
  • 16
0
votes
1 answer

Reading full json file using fromJSON

I'm trying to read in a large JSON file (stored as .txt file) returned by the Yelp API, and convert it into a data frame. My JSON file is in "pretty print" format, the first 3 JSON objects are below: { "businesses": [ { …
Mike C
  • 1
  • 2
0
votes
1 answer

how do you convert a json data to a data frame in R?

I have a variable called data that has json formated data: dput(data) {\"data\": [{\"target\": \"in\", \"datapoints\": [[5, 1423825200000.0], [0, 1423825500000.0], [0, 1423825800000.0], [0, 1423826100000.0], [0, 1423826400000.0], [0,…
user1471980
  • 10,127
  • 48
  • 136
  • 235
0
votes
1 answer

R - Unable to Create a JSON file

I searched the forum and couldn't find a similar question, so I apologize if I may have missed it. Simply, i am given a JSON file and I want to create it. So I thought an easy way to do this is by parsing the file with fromJSON function from…
0
votes
1 answer

Yelp V2 API Query Loop in R

I'm using the Yelp API in R to pull down some businesses. From what I've read in the documentation you can pull down up to 20 businesses per API call, however if you use the offset= parameter you can essentially pull down more records. What I'm…
davids12
  • 323
  • 5
  • 18
0
votes
0 answers

R - Looping through json files using jsonlite

I am writing a script that loops through about 30,000 json files, reading them using jsonlite. However, I always encounter a fatal error like the one below about 5,000 files into my loop. I've written a similar script in python without any issue,…
user2689931
  • 383
  • 1
  • 6
  • 15
1 2 3
33
34