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
2 answers

R jsonlite does not parse JSON as per keys correctly

When converting json to columns in R using jsonlite, I came across a bug where the column values were in the wrong columns. I tried replicating it - R> dt <- data.table(id = 1:2, json = c('{"user": "xyz2", "weightmap": "w1", "domains": "d1"}', …
leoOrion
  • 1,833
  • 2
  • 26
  • 52
1
vote
1 answer

Problem combining rawToChar() and write_json()

I have a problem with rawToChar() and write_json() where my result is a .json file that includes \n and \ and cannot be viewed in a "pretty" manner using notebook+. In addition I can't unfold or Uncollapse the result. My working sequence…
SteveG
  • 99
  • 1
  • 11
1
vote
1 answer

What format of table is at Lineups.com and how to scrape it in R

I am new to scraping and have successfully scraped tables from these…
Abdul Basit Khan
  • 646
  • 1
  • 6
  • 19
1
vote
1 answer

Convert data to Json with all objects included

I want to convert a feature file to json so that I can pass it to a javascript function in an RMD file. However, the toJSON function seems to flatten it and remove many of the fields and structures as below. How can I convert it and keep it in…
Chris
  • 1,449
  • 1
  • 18
  • 39
1
vote
1 answer

Adding a JSON column from specific R dataframe columns

I have an R dataframe with specific columns I want to append together into a JSON column df = data.frame(item = c("Box 1", "Box 2", "Box 3"), Length = c(2, 4, 6), Width = c(4,5,3), Height = c(6, 4, 3)) I want a JSON item dimension column in the df…
Chris
  • 125
  • 7
1
vote
1 answer

R session returning particular error when attempting to work with an API response

I am trying to work with the "httr" and "jsonlite" packages for the first time to work with APIs in R. I have attempted to run the following commands to access the data I need from the appropriate source. res <-…
j_abrams
  • 21
  • 1
1
vote
0 answers

The application failed to start. Contact the author for more information

I just tried to deploy my first shiny app. The first error I got was: Warning messages: 1: In fileDependencies.R(file) : Failed to parse C:/Users/kinde/AppData/Local/Temp/Rtmpu2zAya/filef7c613e1e15/app.R ; dependencies in this file will not be…
Dave4048
  • 173
  • 10
1
vote
1 answer

How to keep the same format as original file when writing a JSON file

I tried out the functionality of the R package jsonlite and not sure why the writting function modifies a bit the structure of the file. Below is a simple example of a file with a given specific structure. I read it and then write it back to disk,…
Valentin_Ștefan
  • 6,130
  • 2
  • 45
  • 68
1
vote
0 answers

toJSON conversion issue

I've been trying to extract multiple DNA-sequence alignments in R (4.0.3) invoking the alignment REST API endpoint from Ensembl. A toy example is below: library(httr) library(jsonlite) tmp_chr = "16" tmp_seq_str = "87187517" …
gokberk
  • 47
  • 7
1
vote
1 answer

R Plumber, How to create nested JSON

Need Help, I just create API with R Plumber, I just would like the Result Json will be like this Instead of like this below are my R Plumber script library(plumber) library(jsonlite) #* @get /nested_json #* @serializer unboxedJSON function() { …
Reza AM
  • 73
  • 6
1
vote
2 answers

Best way to convert a list into a JSON

I have a script that looks something like this (though not exactly because I obviously can't give my API key and what not to make it fully…
user16497487
1
vote
1 answer

jqr package not matching results from jq

person <- GET( "https://api.secure.com/v4/people/111322450?$expand=customFields", accept_json(), add_headers(Accept = 'application/json', Authorization = APIKey) ) capture <- content(person) dput(capture) capture <- list(vanId =…
wizkids121
  • 634
  • 1
  • 9
  • 22
1
vote
1 answer

Parse one column of json and bind with other column to make dataframe

I have data that takes the format: have <- structure(list(V1 = c(4L, 28L, 2L), V2 =…
Eric Green
  • 7,385
  • 11
  • 56
  • 102
1
vote
1 answer

Convert R data frame to custom json

I want to change a data frame to a custom json format at the end. The labels are created from the Date and Pressure column, with name being the value and column name being the group name and need. Below is a way to generate the data frame being used…
Bikash Deb
  • 55
  • 1
  • 7
1
vote
1 answer

R convert dataframe to a nested json file/object grouped by column names

I would like to convert a dataframe into a nested json object, and determine where to create a nested json object based on the column names. I have made a toy example to explain the problem. Given this dataframe: df <-…
Thomas
  • 13
  • 2