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

Import some json data

I would like to import json data in R. I know some discussions are already posted about this subject, but unfortunately I don't have the result I want with these codes or they have many errors with my file. I would like to import…
Cec Jurczyk
  • 87
  • 1
  • 10
2
votes
1 answer

Wrong encoding with fromJSON of jsonlite library

I have converted a json data from a .json file to an R object with using fromJSON() of jsonlite library like this: library(jsonlite) jsonR<-fromJSON(txt="data.json") If I explore the stringed values of the jsonR object I meet some strange…
Andrea
  • 21
  • 2
2
votes
3 answers

Web scraping in R with jsonlite

I am trying to get information about repositories using the github API. I am using R for this. Some urls throw 403 errors. Unfortunately, this stops my function and breaks the fromJSON function. Calling fromJSON again will always result in "client…
user2977636
  • 2,086
  • 2
  • 17
  • 21
2
votes
1 answer

Converting to JSON (key,value) pair using R

My data frame contains data as follows: Tester W1 W2 W3 A P WD(%) TS(Hrs.) AT(Hrs.) SU(%) a 60 40 102 202 150 100 120 120 100 b 30 38 46 114 150 76 135 120 100 c 25 …
sree
2
votes
1 answer

Remove double quotes json created using toJSON

I use the function toJSON like this to create a json: data<-toJSON(list("tablename"= unbox("test.csv"), "header" = header_df, "data" = test1 )) the result is the…
aruizga
  • 644
  • 1
  • 4
  • 19
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
2 answers

multiple JSON objects in fromJSON

I'm trying to use fromJSON() to read in a .json file with multiple objects structured as follows: { "key11": value11, "key12": value12 } { "key11": value11, "key12": value12 } … If I manually add [...] brackets around the entire file, and , commas…
Plastic Soul
  • 484
  • 7
  • 19
2
votes
2 answers

How do I import data from json format into R using jsonlite package

I am doing this newzips=fromJSON("http://media.mongodb.org/zips.json") You can see the data yourself at http://media.mongodb.org/zips.json and getting thus str(newzips) List of 5 $ city : chr "ACMAR" $ loc : num [1:2] -86.5 33.6 $ pop : num…
Ajay Ohri
  • 3,382
  • 3
  • 30
  • 60
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
1
vote
1 answer

Why am I getting a 403 error when connecting to a url that works

I am trying to pull the quarter end dates for a company from the SEC government website. For some reason I keep getting a connection error. The code is working for my friend who is in the US, but not for me in Canada. I tried using a VPN, but was…
Jcrowe10
  • 11
  • 3
1
vote
3 answers

Read a jsonl (json lines) file

Reading a json file could be possible with this commands: library(jsonlite) json_text <- readLines("tect.json", warn = FALSE, encoding = "UTF-8") Parse the JSON data json_data <- fromJSON(txt = paste(json_text, collapse = "")) in a format of data…
Erik Brole
  • 315
  • 9
1
vote
1 answer

Body of a POST request

i'm trying to make a request to get the Acess Token, as described in the second step at https://developers.anbima.com.br/en/visao-geral/autenticacao/ The problem is with the variable body_anbima, the value expected at the server is like REQUEST…
1
vote
1 answer

Problems using fromJSON after API call

I am trying to save some county climate data onto a .csv and have saved some responses that I accessed, using the GET() function for API calls from the httr package. However, when I try to convert the content of the response into a dataframe using…
Alex T.
  • 11
  • 1
1
vote
1 answer

Formatted JSON fro R dataframe

I have a data frame like this…
1
vote
3 answers

Webscrape script variable and convert string into JSON in R

I scrape information with rvest and store it in a dataframe. All information on various institutions and their context characteristics is stored in one string. It looks similar to JSON, but it isn't. I followed another stack post but am not…
Marco
  • 2,368
  • 6
  • 22
  • 48