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

R - cannot read CSV file with JSON string column using data.table and jsonlite because of double backslashes

I have trouble reading a CSV file I exported from a mysql database which contains a column with a JSON string. More concretely, I want to get access to all values in the JSON string. I created a simple example to visualize my problem: This is my CSV…
Daniel
  • 502
  • 6
  • 17
0
votes
1 answer

R - Create valid json with input from R objects

I am looking to create a valid JSON string, with input from an R list. Each key and value needs to be quotation escaped (see expected valid JSON). I use jsonlite package for transform to JSON. The result string is used for an API that requires the…
Toolbox
  • 2,333
  • 12
  • 26
0
votes
1 answer

Avoiding JSON error displaying Japanese strings within Plotly (R) / Running a function on one variable at a time

I'm very new to R and beginner level at programming in general, and trying to figure out how to get hovertext in plotly to display a Japanese string from my dataframe. After venturing through character encoding hell, I've got things mostly worked…
sinaraheneba
  • 781
  • 4
  • 18
0
votes
1 answer

Why can I only read one .json file at a time?

I have 500+ .json files that I am trying to get a specific element out of. I cannot figure out why I cannot read more than one at a time.. This works: library…
OctoCatKnows
  • 399
  • 3
  • 17
0
votes
1 answer

Automatic upload json files via API using R

I want take financial data using API. I do so. #load jsons library("rjson") json_file <- "https://api.coindesk.com/v1/bpi/currentprice/USD.json" json_data <- fromJSON(paste(readLines(json_file), collapse="")) #get json content as data.frame x =…
psysky
  • 3,037
  • 5
  • 28
  • 64
0
votes
1 answer

Converting JSON to data frame with proper column names

I am trying to convert the json below into a data frame: data_toy.json = { "department": { "BME": [ { "course_name": "BMD_ENG_250-0_20 Thermodynamics", "instructor": "Neha Kamat", …
Adam_G
  • 7,337
  • 20
  • 86
  • 148
0
votes
0 answers

Using R to Convert VCI JSON.GZ file to CSV

I have a file that ends with ".vci_json.gz". My goal is to read the contents of this file using R and write contents in a structured table in CSV format. I have attempted using the jsonlite package for R like... dataset1 <-…
sqlbg
  • 73
  • 1
  • 11
0
votes
1 answer

parse json with embedded lists into semi-long dataframe

I have a json file with several layers of nesting, and I am struggling to get it into a workable dataframe. I created a toy example of mock data based on a real structure: here is the gist. And here is my desired output. The output could be "longer"…
Eric Green
  • 7,385
  • 11
  • 56
  • 102
0
votes
1 answer

Unable to load multilevel JSON into data frame using R

I am unable to load this nested JSON into a data frame. require(RJSONIO) sample_json2 <- '[{ "_id" : { "$oid" : "50b59cd75bed76f46522c34e" }, "student_id" : 0, "class_id" : 2, "scores" : [ { "type" : "exam", "score" : 57.92947112575566 }, {…
0
votes
0 answers

Scraping with jsonlite library

I´m trying to scrape a webpage using jsonlite library as it follows: page <- jsonlite::fromJSON("http://divulgacandcontas.tse.jus.br/divulga/rest/v1/candidatura/buscar/2018/GO/2022802018/candidato/90000609234") data <- dplyr::bind_rows(page) The…
jvqp
  • 239
  • 3
  • 14
0
votes
1 answer

Pulling JSON Data into R Dataframe

I am trying to pull JSON lunar cycle data from the USNO API. The problem is that there are two arrays of JSON data in what I get back. I don't see a way to specify what I get back from the Observatory, so I think I need to clean it up in R. Here…
TimL
  • 49
  • 5
0
votes
2 answers

Loading .log file in R

I have big data.log file, a few line examples below. I want to convert it to data frame for EDA. {"date":"2018-03-29T12:49:25.308+0000","level":"INFO","message":"User…
eagle23
  • 35
  • 6
0
votes
1 answer

How to flatten a deeply and irregularly nested list/dataframe/JSON in R

I would like convert json file to dataframe (without any nested list inside a dataframe) temp <- jsonlite::fromJSON(txt ="https://unstats.un.org/SDGAPI/v1/sdg/GeoArea/Tree")
Mohamed
  • 95
  • 7
0
votes
1 answer

Make a JSON from list in R

I am trying to make following JSON in R: test_json <- '{ "PropertyValues": [{"PropertyDef": 100, "TypedValue": { "DataType": 9, "HasValue": false, "Value": null, "Lookup": { "Deleted": false, "DisplayValue": null, "Hidden": false, …
Mislav
  • 1,533
  • 16
  • 37
0
votes
0 answers

Rjsonio vs jsonlite lexical error

New to this so please excuse any mistakes. I am using R to convert some JSON files and using JSONLITE is perfect in relation to the format that it produces. However I keep getting a lexical error similar to the below Error in parse_con(txt,…