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
1 answer

jsonlite suddenly retunring error: "Failure when receiving data from the peer"

Suddenly, over the weekend, my code is no longer working. when I run it, I receive the following message: Error in parse_con(txt, bigint_as_char) : Failure when receiving data from the peer the code is the following: raiz <-…
motabe
  • 101
  • 1
  • 6
0
votes
0 answers

Importing json with jsonlite results in error

I'm simply trying to read a file.json with the read_json() function from the jsonlite package. I get this error: mydata <- read_json(path="file.json",simplifyVector = TRUE) Error in parse_con(txt, bigint_as_char) : parse error: trailing garbage …
delcast
  • 496
  • 1
  • 5
  • 16
0
votes
1 answer

R dataframe to JSON array of objects

I have an R dataframe in the following format id code value 1 A 3 2 B 5 3 C 9 using: toJSON(df) returns: [{id:1,code:A,value:3},...] My desired output is: [{1,A,3},{2,B,5}..] using df <- unname(df) returns an array…
someone
  • 149
  • 8
0
votes
1 answer

How to convert data frame to JSON array using R

In my current project, I am trying to read data from csv file and trying to create hierarchical JSON array based on the data from csv file in R. Sample data is shown below: Added data sample data (Reduced the dataset for simplicity): Country …
Saurabh Chauhan
  • 3,161
  • 2
  • 19
  • 46
0
votes
0 answers

How to load certain number of rows into dataframe from big JSON?

I have 10 GB JSON file containing tweets and I'm trying to load it in R using stream_in function from litejson package. I want to load just some number of rows, not whole file. Is there a way to do it?
Nata
  • 171
  • 3
  • 15
0
votes
1 answer

jsonlite is creating a data.frame with a column of class data.frame

My json file is being read into R as a list by json_lite::read_json(). To recreate my problem, save the code below as a .json file from any text editor, the file can then be read into R. { "data": [ { "type": "invite", "send_date":…
Joe
  • 3,217
  • 3
  • 21
  • 37
0
votes
1 answer

How to parse Json in R corresponding to ID

I have below mentioned dataframe: ID Json_Data PA-124 Json String PA-145 Json String PA-185 Json String PA-149 Json String I want to extract all the json field corresponding to each ID as mentioned below. And I would like to…
Roy1245
  • 507
  • 4
  • 18
0
votes
1 answer

meetup rate limit only 200, problems with getting other records

I am trying to get events for a meetup. The problem is I am only getting around 200 events. So, I tried doing an offset and specifying the pagination as specified in other stackoverflow question but is not working. It is giving me the same records…
user3570187
  • 1,743
  • 3
  • 17
  • 34
0
votes
2 answers

r- Accessing json value using jsonlite or Regex

I am trying to access a value from json by using jsonlite package, but the value (the value of key strongbuy where the period is 0m) I am trying to access has the same key name (period -1m has the same key name), so it returns NA value. Is there a…
user9532692
  • 584
  • 7
  • 28
0
votes
1 answer

Need to use jsonlite to handle ndjson message list using stream_in() and stream_out()

I have an ndjson data source. For a simple example, consider a text file with three lines, each containing a valid json message. I want to extract 7 variables from the messages and put them in a dataframe. Please use the following sample data in a…
ds_guy
  • 143
  • 2
  • 5
0
votes
2 answers

Return NA when missing item in json

I’m having in a function that iterates through several jsons some code like below: my_tibble <- tibble(col_a = json$xyz$xyz, col_b = json$xyz2$xyz2, col_c = json$xyz3, ...) I would like to have a NA returned if for instance col_b is missing in the…
MattnDo
  • 444
  • 1
  • 5
  • 17
0
votes
1 answer

Using Purrr to append to files

I want to use purrr::map() to append a new column to a list of json files containing a table with an id variable as an identifier. I read the files this way: path <- "my_path" files <- dir(path, pattern = "*.json") data <- files %>% …
Monduiz
  • 711
  • 10
  • 22
0
votes
0 answers

R language: remove backslash when pasting JSON to URL using jsonlite

I'm using R and I have a webpage that wants JSON formatted data to return what I want. However, when I set up a JSON object and paste it to my URL, R adds escape chars (backslash) to the double quotes in the JSON object. And I want to remove the…
habana
  • 317
  • 1
  • 11
0
votes
0 answers

fromJSON reading a list of characters

This is a follow-up from doing multiple fromJSON queries (jsonlite). Not sure if it's ok to post separate but related questions. following @parfait 's suggestion, I tried to create a list of URLs in a list so that fromJSON can be applied to it.…
ZJC
  • 1
  • 1
0
votes
2 answers

doing multiple fromJSON queries (jsonlite)

I'm a newbie R user and couldn't find any answers which I could understand. My objective is to retrieve information from a URL and then convert the information into a data frame for…
ZJC
  • 1
  • 1