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:

419 questions
5
votes
2 answers

How to merge data in to a pre-existing JSON structure in R?

First time poster, long time lurker. Be gentle. Moderate R user. I am sure there is a better, functional way to do what I need, but felt like I have researched do death with no insight. I am trying to merge a data set to a pre-existing JSON…
p0wd3rd
  • 53
  • 5
5
votes
1 answer

R - Serialize R models as JSON

Is there some good R package that can convert prediction models and other complex object to and from JSON? I have linear regression model from this example: eruption.lm = lm(eruptions ~ waiting, data=faithful) newdata =…
Jovan MSFT
  • 11,158
  • 4
  • 35
  • 43
5
votes
2 answers

JSON (using jsonlite) parsing error in R

I have the following JSON file: {"id":1140854908,"name":"'Amran"} {"id":1140852651,"name":"'Asir"} {"id":1140855190,"name":"'Eua"} {"id":1140851307,"name":"A Coruna"} {"id":1140854170,"name":"A`Ana"} I used the package jsonlite but I get a…
user3006691
  • 395
  • 2
  • 5
  • 16
5
votes
1 answer

Import multiple json files from a directory and attaching the data

I am trying to read multiple json files into a working directory for further converting into a dataset. I have files text1, text2, text3 in the directory json. Here is the code i wrote: setwd("Users/Desktop/json") temp =…
user3570187
  • 1,525
  • 1
  • 15
  • 29
4
votes
1 answer

Nested R dataframe to JSON with objects instead of arrays

I need to convert a dataframe to JSON. There are several nested dataframes as variables in the dataframe to convert to JSON. But, when converting to JSON, I need the data for Values1 described below to be an object (enclosed in {} only) instead of…
Megan Beckett
  • 317
  • 1
  • 5
4
votes
1 answer

How to parse a file with stacked multiple JSONs in R?

I have the following "stacked JSON" object within R, example1.json: {"ID":"12345","Timestamp":"20140101", "Usefulness":"Yes", "Code":[{"event1":"A","result":"1"},…]} {"ID":"1A35B","Timestamp":"20140102", "Usefulness":"No", …
ShanZhengYang
  • 12,508
  • 35
  • 106
  • 190
4
votes
1 answer

get wrong result by converting json string containing large number by using jsonlite

Here is the MWE, how to get the correct number as character. require(jsonlite) j <- "{\"id\": 323907258301939713}" a <- fromJSON(j) print(a$id, digits = 20) class(a$id) a$id <- as.character(a$id) a$id class(a$id) Here is the output. Loading…
Christophe
  • 165
  • 2
  • 8
4
votes
1 answer

Converting a dataframe to nested json format

I am dealing with a r dataframe which looks like this below. id date items price 10 2014/09/13 shoes 187 10 2014/09/13 belt 35 10 2014/09/14 shirt 69 …
Kim Jenkins
  • 430
  • 2
  • 16
4
votes
1 answer

Extract, format and separate JSON already stored in a data frame column

How might I parse and process JSON that already lives inside a data frame? Sample data: df <- data.frame( id = c("x1", "x2"), y = c('[{"Property":"94","Value":"Error"},{"Property":"C1","Value":"Found…
emehex
  • 7,082
  • 8
  • 46
  • 85
4
votes
1 answer

Importing JSON into R with in-line quotation marks

I'm attempting to read the following JSON file ("my_file.json") into R, which contains the following: [{"id":"484","comment":"They call me "Bruce""}] using the jsonlite package (0.9.12), the following…
WMC
  • 111
  • 1
  • 9
3
votes
1 answer

Not able to extract data from API using R

I have below mentioned dataframe in R: DF ID Code PO-1 123 PO-3 345 PO-4 222 I want to pass the ID in api get specific response from the JSON. I have the api like "https://test.com/path/code-info?ID=PO-1" with header…
Sophia Wilson
  • 461
  • 2
  • 11
3
votes
1 answer

Add JSON column to R dataframe

I have a data frame and want to add an additional column that contains the data per row in JSON format. In this example: dfr = data.frame(name = c("Andrew", "Mathew", "Dany", "Philip", "John", "Bing", "Monica"), age = c(28, 23, 49, 29, 38, 23,…
StefanG
  • 1,146
  • 1
  • 18
  • 41
3
votes
1 answer

How to use readLines in R to read all lines between a certain range?

I am trying to split a large JSONL(.gz) file into a number of .csv files. I have been able to use the code below to create a working .csv file, for the first 25.000 entries. I now want to read and parse the 25.001 to the 50.000th line, and have been…
Frank
  • 33
  • 1
  • 4
3
votes
1 answer

C# JSON parse instead of R

Suppose I have a nested json file which looks like…
Mikey
  • 145
  • 1
  • 12
3
votes
1 answer

R errors in loop: file(con, "r") and open.connection(con, "rb")

I am downloading a series of urls which are JSON files, into a list of list, to be analyzed later. baseurl <- "http://zoeken.kvk.nl/Address.ashx?site=handelsregister&partialfields=&q=010" pages <- list() for(i in 1:99999){ if(i <…
RobertHaa
  • 69
  • 2
  • 9
1
2
3
27 28