Questions tagged [rjson]

Converts R object into JSON objects and vice-versa

rjson is an package for woking with , allowing JSON objects to be imported as R objects, and R objects to be serialized as JSON.

Repositories

Vignettes

Other resources

Related tags

135 questions
3
votes
2 answers

Processing JSON using rjson

I'm trying to process some data in JSON format. rjson::fromJSON imports the data successfully and places it into a quite unwieldy list. library(rjson) y <-…
James
  • 65,548
  • 14
  • 155
  • 193
2
votes
2 answers

JSON file to R dataframe

I have a JSON file. While the original file is quite large, I reduced to a much smaller reproducible example for the purposes of this question (I still get the same error no matter what size): { "relationships_followers": [ { "title":…
wizkids121
  • 634
  • 1
  • 9
  • 22
2
votes
5 answers

How can I best flatten a nested list to a data.frame in R?

I would like to convert information from a rest api, which comes in form of json, to a data.frame. The list is nested and theoretically I could repeatedly call purrr::flatten() to get to the bottom of the list and then extract the information using…
Patrick Balada
  • 1,330
  • 1
  • 18
  • 37
2
votes
2 answers

Why is httr not reading a response-class object?

I'm trying to update a project from March 2018. Previously, I had used library("httr") library("rjson") api.url <- "http://api.tvmaze.com/lookup/shows?imdb=tt1325113" response <- GET(api.url) response.list <- fromJSON(content(response)) Previously,…
Jamie B
  • 23
  • 2
2
votes
1 answer

Regex pattern to retrieve data from a JSON format, takes too much time because is not specific enough

I have a problem when I try to retrieve data from a JSON structure. I can see a pattern but I don't see a clear way of doing it at the same time general and efficient. The data I am using is the one corresponding to TMDB Box Office Prediction from a…
user123
  • 175
  • 4
  • 16
2
votes
1 answer

Extract string from JSON using grep

I have a JSON input: { "policyItems": [ { "accesses": [ { "type": "submit-app", "isAllowed": true } ], "users": [], "groups": [ "Application_Team_1", "team2" ], …
vero
  • 1,005
  • 6
  • 16
  • 29
2
votes
2 answers

Skip NULL value in JSON in R

Hey, guys! I have simple R script for parse JSON file: json <- rjson::fromJSON(readLines('http://data.rada.gov.ua/ogd/zpr/skl8/bills- skl8.json', warn=F)) bills <- data.frame( id = numeric(), title = character(), type = character(),…
2
votes
1 answer

rjson::fromJSON returns only the first item

I have a sqlite database file with several columns. One of the columns has a JSON dictionary (with two keys) embedded in it. I want to extract the JSON column to a data frame in R that shows each key in a separate column. I tried rjson::fromJSON,…
N.Hamoud
  • 33
  • 6
2
votes
1 answer

Google api returning wrong values

can you help me with extracting info from google API, when i supply address variable: 560066, 560065 (pincodes of bengaluru city), the address_components has different lengths (4 and 5 in this case) This could return wrong data. Let say i wanted…
Itachi
  • 2,817
  • 27
  • 35
2
votes
0 answers

How to POST and retrieve data from a database in R using REST API?

I need to call an API within R which will make the request to a database server and fetch the results into an R dataframe. The API I have is of the form: http://servername01.home.local/tech-myobjectapi-0.3/myObjectApi/api/v2/Object I also have to…
j1897
  • 1,507
  • 5
  • 21
  • 41
2
votes
0 answers

Rjson readin large Json error

I'm trying to read in a 2.4GB json file into R, However, it seems using the routine approach does not work. The error is below. What can I do? Error in paste(readLines(file, warn = FALSE), collapse = "") : The result will exceed 2^31-1 BYTE
user3329081
  • 337
  • 4
  • 15
2
votes
2 answers

Converting date in R to JSON format

I want to convert date in to JSON format. The R all.elasticities data.frame looks like this: PREVIOUS_START_DATE PREVIOUS_PRICE PREVIOUS_QUANTITY PRE_No_OF_WEEKS CURRENT_START_DATE 2015-12-20 2.79 20680.5 …
sayali
  • 97
  • 6
2
votes
0 answers

lapply skipping over the first function argument

Is it possible run lapply such that the X list argument is used as the second argument to FUN and the first argument to FUN is skipped? One example is rjson::fromJSON(json_str, file, [other arguments]). I have a list containing several file paths of…
Jon Claus
  • 2,862
  • 4
  • 22
  • 33
2
votes
1 answer

Wrong encoding with fromJSON of jsonlite library

I have converted a json data from a .json file to an R object with using fromJSON() of jsonlite library like this: library(jsonlite) jsonR<-fromJSON(txt="data.json") If I explore the stringed values of the jsonR object I meet some strange…
Andrea
  • 21
  • 2
2
votes
1 answer

R create JSON in R

I want to get to get the values from this JSON string: { "item": [ { "value": 142 } , { "value": 200 } ] } R code: library(rjson) item <- list(item=c(value= 142,value=200)) toJSON(item) And I have: > toJSON(item) [1]…
Shen
  • 183
  • 1
  • 10
1
2
3
8 9