Questions tagged [rjsonio]

RJSONIO is an R package that allows conversion to and from data in Javascript object notation (JSON) format. This allows R objects to be inserted into Javascript/ActionScript code and allows R programmers to read and convert JSON content to R objects.

RJSONIO is an package that allows conversion to and from data in Javascript object notation () format. This allows R objects to be inserted into / code and allows R programmers to read and convert JSON content to R objects. It is an alternative to the rjson package. The RJSONIO package uses methods, vectorized operations and code and callbacks to R functions for deserializing JSON objects to R. It allows fast parsing of large JSON documents.

The primary functions in the package are

  • fromJSON
  • toJSON
  • asJSVars

The package is extensible, allowing others to define S4 methods for toJSON for different R classes/types. Similarly, the fromJSON function allows the caller to specify a different callback handler which is invoked each time an element (e.g. number, string, key, start or end of an array or object) is found in the JSON content.

Repositories

Other resources

Related tags

83 questions
2
votes
1 answer

RJSONIO rounding error

I have a problem with the toJSON function in RJSONIO package in R. Values seem to be rounded when reading from a data frame. I would like to understand whether this is a bug or something deeper within R. Here is a reproducible example: sal <-…
whanrott
  • 73
  • 7
2
votes
1 answer

How to correctly deal with escaped Unicode Characters in R's library RJSONIO when reading json from a file

I am using R's RJSONIO to read json from a file. The json contains unicode characters, which get read incorrectly. The code works when the json is passed as string as shown by the author of the R package in the question on stackoverflow How to…
2
votes
0 answers

Ability to JSON serialize and deserialize int64 with precision in R

In R, Int64 whole numbers can not be accurately serialized to and from JSON, because existing JSON libraries will coerce the value into a numeric, or expect to represent the number in scientific notation. Does anyone know of a way to accurately…
Val H
  • 507
  • 4
  • 13
2
votes
2 answers

R data.frame to JSON with child nodes / hierarchical

I am trying to write a data.frame from R into a JSON file, but in a hierarchical structure with child nodes within them. I found examples and JSONIO but I wasn't able to apply it to my case. This is the data.frame in R > DF Date_by_Month CCG…
Sylvia
  • 315
  • 2
  • 17
2
votes
1 answer

Using data.table and RJSONIO / jsonlite - results are transposed

I have implemented a wrapper library part of rstudio's htmlwidgets that renders a pivot table. The package is here. The package works well with data.tables and data.frame (as it should!). For example it works with iris. On the other hand if I try to…
Enzo
  • 2,543
  • 1
  • 25
  • 38
2
votes
1 answer

R: Handling error response in JSON format

I am requesting user details to the Facebook Graph API, such as require(RJSONIO) response <- RJSONIO::fromJSON("http://graph.facebook.com/?ids=Jack") print(response) # $Jack # id first_name gender last_name locale #…
CptNemo
  • 6,455
  • 16
  • 58
  • 107
2
votes
3 answers

Converting a matrix/dataframe in R to JSON object with some constraints

REDITED: I have to convert a matrix in R to a JSON object with some structure in it. I am using the rjson package. Through an example, let me illustrate what I want. My specific case is the output of a recommender system code in R where the X2 X3…
user2878729
  • 61
  • 1
  • 5
2
votes
1 answer

R httr POST of JSON returns status 400

I'm working on a few functions to get data from StatBank Denmark, and their API. They have made a console to test JSON calls and I know the basic_request I parse to JSON in the function dst_get_data works, as I have tested it in the console. I get a…
KERO
  • 705
  • 6
  • 15
2
votes
1 answer

fromJSON only reads first line in R

I've got a sample JSON file with about 500 tweets which I'd like to get into a dataframe. The first three tweets from the JSON file are as follows (urls have been changed deliberately to fit within stackoverflow rules on…
2
votes
1 answer

Convert data frame to JSON in this format

I have a data frame that I'm looking to output to JSON in a particular format, with a small sample below: dat <- structure(list(unit = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L), .Label = c("A", "B"), class = "factor"), type = structure(c(1L, …
Tommy O'Dell
  • 7,019
  • 13
  • 56
  • 69
2
votes
1 answer

Parsing text file of one line JSON objects using RJSONIO

What I want: I would like to parse a text file of the form {"business_id": "rncjoVoEFUJGCUoC1JgnUA", "full_address": "8466 W Peoria Ave\nSte 6\nPeoria, AZ 85345", "open": true, "categories": ["Accountants", "Professional Services", "Tax Services",…
AlexLordThorsen
  • 8,057
  • 5
  • 48
  • 103
2
votes
1 answer

Parsing data frame to JSON (via RJSONIO)

I have an issue with RJSONIO. I have a data frame like df df <- data.frame(a = c(1:3), b = c(4:6), c = c(7:9) ) df a b c 1 1 4 7 2 2 5 8 3 3 6 9 Now what I need is to use this data frame and generate the rows in the following JSON structure. So…
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

Read from JSON where URL contains funny character

I am trying to read from an API where the URL contains a non-standard latin character in R, but am getting an error. Similar URLs without a funny character work fine. I get following error >…
bc17568
  • 13
  • 2
1
vote
1 answer

Extracting json values using a key

I have a JSON string called test in which some elements contain more than one key (for example, foo and bar). My goal is to only extract the values of foo. How can one do this with R? I have tried converting to both matrix and data.frame but this…
iskandarblue
  • 7,208
  • 15
  • 60
  • 130