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
1
vote
0 answers

How to unnest fields in json that contain map coordinates int list column in r?

I have read json .txt file and looking to extract geometry & coordinates field from the data which is nested inside. But having issues in unnesting coordinates data due to list column in…
ViSa
  • 1,563
  • 8
  • 30
1
vote
1 answer

Scraping JSON from a password protected forum in R

I have a problem reading data from a JSON file on a forum that requires login to access. I am using rvest package and to read an html page after login this code works well. But my doubt is how I read a JSON file using the same session where the user…
Bruno G
  • 21
  • 3
1
vote
1 answer

Convert tibble/dataframe to JS array in R

Say you have the following data: library(tibble) offset <- tribble( ~index, ~month, 0, "Jul", 1, "Aug", 2, "Sep", 3, "Oct" ) How would one go about converting offset into the following JavaScript friendly array? 'offset': { 0: 'Jul', …
tomasu
  • 1,388
  • 9
  • 11
1
vote
0 answers

"Undefined index error" when reading a json output from a url using fromJSON in R while reading the same data from a text file works

I am using R. Consider this url with a query string. url_bbmp <-…
Lazarus Thurston
  • 1,197
  • 15
  • 33
1
vote
1 answer

How to make a new request while there is an error? (fromJSON)

I have a code where I make requests for an API using the jsonlite package. My request is: aux <- fromJSON (www ... js) The problem is that there is a time limit on requests and sometimes the error is returned: *Error in open.connection (con, "rb"):…
1
vote
0 answers

Avoid unboxing for vectors with 1 value

For an API I wish to push data to, I need to avoid unboxing to happen on specific values. Consider the following input: library(jsonlite) lsA <- list(propertyName = "listA", Values = c("x")) lsB <- list(propertyName = "listB", …
BroQ
  • 101
  • 6
1
vote
1 answer

how to convert json to tibble

I have the following json data {"data": {"cat1": ["value1", "value2", "value3", "value4", "value5"], "cat2": ["aaa", "bbb", "ccc"]},"info": ""} I want to convert the data to the following. How can I do that using function…
1
vote
1 answer

Joining character and numeric json elements in R

I am trying to join two json objects into a single json object in R using jsonlite. As a simple illustration, if I have the following: The api that I am using needs a Json object that has the column names of a dataframe as the first element,…
Nick
  • 3,262
  • 30
  • 44
1
vote
1 answer

R Jsonlite - How to iterate a JSON list of objects?

I'm very new in R, but I was tasked with reading a JSON file that looks like the following : { "revisions" : [ {"number": 1, "description" : "first revision"}, {"number": 2, "description" : "second revision"}, {"number": 3,…
Mojimi
  • 2,561
  • 9
  • 52
  • 116
1
vote
1 answer

Parse json with big integer in R

I have json "{\"old_value\":\"Active\",\"new_value\":\"Inactive\",\"campaign_id\":23845817785350401,\"type\":\"run_status\"}" with campaign_id = 23845817785350401 as integer. When I'm trying to parse it, I have some…
jyjek
  • 2,627
  • 11
  • 23
1
vote
0 answers

How to merge two JSON objects in R by keeping both json structure

I have two separate objects in R which have a JSON format and I'm trying to convert into a single R objects with two JSON objects in it's structure this is my code.. studies <- get_studies(efo_trait = 'triple-negative breast cancer') study <-…
1
vote
1 answer

Unnest multiple columns from json

I am wondering if there is a simpler solution to unnesting some JSON into a dataframe. I have the following JSON from an API: library(tidyverse) library(jsonlite) json <- '{ "result": { "id": "id_1", "description": "description", …
CGP
  • 129
  • 8
1
vote
1 answer

Using jsonlite to parse json string with number labels

I'm retrieving a json string from an API (over which I have no control) that looks like the following: { "data": [ { "6": { "value": "Jamie Stein" }, "7": { "value": 10 } …
1
vote
1 answer

Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, : arguments imply differing number of rows: 0, 588

I'm trying to work with an API from the NS (Dutch train company). I want to have it in a dataframe format but I get this error when I run the following code: NSspoorkaart <- GET("https://gateway.apiportal.ns.nl/Spoorkaart-API/api/v1/spoorkaart", …
1
vote
1 answer

HTTR package is not returning full response from API query

I am trying to use httr to call on an API from IGDB (documentation here). When I use the following query in Postman, I have no problem and get the full request which has 100 entries: fields rating, game; where game = 114283; limit 100; sort id…
lolwatpie
  • 111
  • 1
  • 1
  • 3