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

Flattening list with variable nesting levels creates additional observations

I have a nested list of geocoded Moscow street addresses, converted from a nested list. However, the dataframe I was geocoding from had only addresses without zip codes, and in a few hundred (out of 33k) cases, the address returned multiple results…
Sean Norton
  • 277
  • 1
  • 12
0
votes
1 answer

R: jsonlite's stream_out function producing incomplete/truncated JSON file

I'm trying to load a really big JSON file into R. Since the file is too big to fit into memory on my machine, I found that using the jsonlite package's stream_in/stream_out functions is really helpful. With these functions, I can subset the data…
0
votes
0 answers

Addition of special characters in text string in R

I'm trying to use R to create some API requests and using the jsonlite package to do so. I have an element in my JSON request named selected that needs to be set to "::total::": "". Everything I have tried results in the addition of a "\". I…
0
votes
1 answer

Printing double quotes of unnamed list with toJSON

I have json data that I'm importing to R and then exporting in the exact same format. The original code looks like: "Entries":{"":11.8988438} Using names<-(""), I can reproduce the double quotes in R, but when writing with write_json(x), I've only…
Kyouma
  • 320
  • 6
  • 14
0
votes
0 answers

Error in fromJSON in R

I am trying to convert JSON file into data frame in R and had this error when I ran fromJSON in 'jsonlite' package. Error in fromJSON(content, handler, default.size, depth, allowComments, : Invalid JSON Node I figured that the variable order…
Emily
  • 305
  • 3
  • 13
0
votes
1 answer

Convert json fetched into dataframe using R

I've json like below, which i got from below URL: { "info" : { "1484121600" : [ 212953175.053333,212953175.053333,null ], "1484125200" : [ 236203014.133333,236203014.133333,236203014.133333 ], …
Ashag
  • 837
  • 2
  • 15
  • 24
0
votes
2 answers

Combining two lists into a JSON in R

I have two lists - test.segments - which represents timestamps and the second - test.coords - which represents lat/lon coordinates. The number of elements in each list is equal - so both should theoretically be easily combined. >…
iskandarblue
  • 7,208
  • 15
  • 60
  • 130
0
votes
1 answer

Rselenium Jsonlite scraping

I am new at Scraping. I am trying to scrape the table that appears in a site and transform into a dataframe but it seems that I have to execute a Script. I am using Rselenium approach. Probably Jsonlite works better, but I don´t know how. # Running…
Ushuaia81
  • 495
  • 1
  • 6
  • 14
0
votes
1 answer

R: Web scraping JSON, extracting information from nest

I am trying to use tidyJSON to extract information from JSON, but I am open to any R package that can achieve my ends. I took a look at the documentation and vignittes and found the complex example was helpful. However, the information I want is…
user2205916
  • 3,196
  • 11
  • 54
  • 82
0
votes
1 answer

From list of json files to data.table: partial variable list

I have a list of more than 100,000 json files from which I want to get a data.table with only a few variables. Unfortunately the files are complex. The content of each json file looks like: Sample 1 $id [1] "10.1" $title $title$value [1] "Why this…
user2627717
  • 344
  • 3
  • 14
0
votes
1 answer

R: Expand column of dataframes in existing dataframe

I am using jsonlite::fromJSON to get a JSON document to a dataframe. The problem is that it is not getting flattened completely - for reasons not known to me (but someone below has mentioned because they are in the form of a dictionary, they won't…
Komal Rathi
  • 4,164
  • 13
  • 60
  • 98
0
votes
1 answer

Writing looped web scrape to excel sheets

I am trying to scrape web data using a loop and write each instance into a different sheet in the same excel file. I have included the script below. The sheet names are correctly created, but the same dataframe is written into both sheets. Really…
Dan L
  • 57
  • 5
0
votes
1 answer

Extracting all the information from an uncommon JSON structure in R

In a previous post (How do I read multiple JSON structures contained in one file?) I have asked about an uncommon data structure (or at least uncommon for R) I have a txt file with this structure: identifier ### part A ### part B A simplification…
pachadotdev
  • 3,345
  • 6
  • 33
  • 60
0
votes
0 answers

Disaggregating nested JSON data in R

I have data in a JSON file that looks like this: [{"Mordecai": {"Location": [{"lat": "-17.82772", "lon": "31.05337", "name": "Harare", "countryCode": "ZWE"}, {"lat": "-17.3", "lon": "31.33333", "name": "Bindura", "countryCode": "ZWE"}]}},…
Beatrix
  • 11
  • 3
0
votes
1 answer

I am accessing an api for data and am not able to the columns in r

I am using httr in order access data from an api and then save that data so that I can begin to do some data validation. I am having an issue accessing the columns and rows I think because the data has been stored as a nested list. query2 <- "this…
N.M
  • 1