Questions tagged [rjson]

Converts R object into JSON objects and vice-versa

rjson is an package for woking with , allowing JSON objects to be imported as R objects, and R objects to be serialized as JSON.

Repositories

Vignettes

Other resources

Related tags

135 questions
46
votes
4 answers

R convert dataframe to JSON

I have a dataframe that I'd like to convert to json format: my data frame called res1: library(rjson) structure(list(id = c(1, 2, 3, 4, 5), value = structure(1:5, .Label = c("server1", "server2", "server3", "server4", "server5"), class =…
user1471980
  • 10,127
  • 48
  • 136
  • 235
25
votes
2 answers

How can I convert Json to data frame in R

I'd like to convert my json data to data frame in R. Here is what I've done so far: library("rjson") result <- fromJSON(file ="mypath/data.json") json_data_frame <- as.data.frame(result) However, it comes to an error like this: Error in…
Ping Yi Hsu
  • 253
  • 1
  • 3
  • 5
17
votes
2 answers

RJSONIO vs rjson - better tuning

UPDATE: The tl;dr is that RJSONIO is no longer the faster of the two options. Rather rjson is now much faster. See the comments for additional confirmation of results I was under the impression that RJSONIO was supposed to be faster tha…
Ricardo Saporta
  • 54,400
  • 17
  • 144
  • 178
12
votes
1 answer

Scraping NBA data in R with rjson

I have been spending a long time using R to try to scrape NBA data, so far I was doing it a little by trial and error, but finally I found this documentation. Some time ago I had some problems scraping the shotchartdetail, and I figured out the…
Derek Corcoran
  • 3,930
  • 2
  • 25
  • 54
12
votes
2 answers

What are "reverse dependencies" in R?

I have to install the rjson package in R and looking at the CRAN page that deals with the package I saw that rjson has different dependencies: Reverse depends: couchDB, df2json, edeR, gooJSON, indicoio, kintone, notifyR, RDSTK, Rfacebook, rJython,…
QuantumGorilla
  • 583
  • 2
  • 10
  • 25
10
votes
3 answers

How to import JSON into R and convert it to table?

I want to play with data that is now saved in JSON format. But I am very new to R and have little clue of how to play with data. You can see below what I managed to achieve. But first, my code: library(rjson) json_file <-…
Aidis
  • 1,272
  • 4
  • 14
  • 31
8
votes
1 answer

"Error in library(rjson): There is no package called rjson"

My rjson package randomly doesn't work. As in, it works fine sometimes, sometimes it fails to load. Not sure why. I get this error. Error in library("rjson") : there is no package called ‘rjson’ To try and alleviate this, despite knowing its…
Jibril
  • 967
  • 2
  • 11
  • 29
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,743
  • 3
  • 17
  • 34
5
votes
1 answer

create empty object (empty brackets) with toJSON

I need to create a JSON string from R using toJSON. My issue is that part of the JSON should contain an empty JSON object {}. I thought list() would do it for me: > fromJSON("{}") list() > toJSON(list()) [1] "[]" [Scratches head] Anybody know how…
mattexx
  • 6,456
  • 3
  • 36
  • 47
5
votes
2 answers

How to replace "unexpected escaped character" in R

When I try to parse JSON from the character object from a Facebook URL I got "Error in fromJSON(data) : unexpected escaped character '\o' at pos 130". Check this out: library(RCurl) library(rjson) data <-…
4
votes
1 answer

How to convert json file into dataframe in R?

I have a json text file which reads {"type":"session.ended","v":2,"post.source":"1306210600-col001.sv1.movenetworks.com:2097#5","post.ip4":"75.114.187.146","post.rtime_secs":1371794661,"post.rtime_text":"2013-06-21…
user3190185
  • 63
  • 1
  • 4
3
votes
0 answers

Convert json object to dataframe- character '0' is not recognized

I am trying to convert this json object to a data frame. I am getting an error that character '0' is not recognized. Any suggestion on how to handle this error occurring in a large json file having 1000 records? library(RJSONIO) json_file<- '{…
user3570187
  • 1,743
  • 3
  • 17
  • 34
3
votes
2 answers

rjson: Convert `list` to JSON-like string compatible with Cypher DSL

Let's have: desired_output="{a:'1', b:'foo'}" D = list(a=1, b="foo") Then: out = toJSON(D) out "{\"a\":1,\"b\":\"foo\"}" identical(out, desired_output) # FALSE Is there a better function f (other than gsub) so that this holds? identical(…
Daniel Krizian
  • 4,586
  • 4
  • 38
  • 75
3
votes
2 answers

R: Data frame to json array object

Im trying to get JSON array object from data frame where each JSON object is a subset of data frame > x <- 1:5 > y <-c('a','b','c','d','e') > z <-c(1,1,1,2,2) > df <-data.frame(x,y,z) > df x y z 1 1 a 1 2 2 b 1 3 3 c 1 …
3
votes
2 answers

Problems reading JSON file in R

I have a JSON file (an export from mongoDB) that I'd like to load into R. The document is about 890 MB in size with roughly 63,000 rows of 12 fields. The fields are numeric, character and date. I'd like to end up with a 63000 x 12 data frame.…
SCallan
  • 681
  • 9
  • 26
1
2 3
8 9