jsonlite

Recursively ensuring tibbles instead of data frames when parsing/manipulating nested JSON

試著忘記壹切 提交于 2020-01-21 14:02:26
问题 I have to deal with JSON documents that contain nested documents and at some level have an array which in turn contains individual documents that conceptionally would map back to "data frame rows" when reading/parsing the JSON in R. First order problem/question I'm looking for a way to ensure that either all data frames are always turned into tibbles or that at least the "leaf data frames" become tibbles while the the "parent data frames" are allowed to become lists for arbitrary nested

Recursively ensuring tibbles instead of data frames when parsing/manipulating nested JSON

血红的双手。 提交于 2020-01-21 14:02:05
问题 I have to deal with JSON documents that contain nested documents and at some level have an array which in turn contains individual documents that conceptionally would map back to "data frame rows" when reading/parsing the JSON in R. First order problem/question I'm looking for a way to ensure that either all data frames are always turned into tibbles or that at least the "leaf data frames" become tibbles while the the "parent data frames" are allowed to become lists for arbitrary nested

Ensure that data frames become tibbles when reading MongoDB data with {mongolite}

帅比萌擦擦* 提交于 2020-01-16 08:12:09
问题 I have to deal with JSON documents that contain nested documents and at some level have an array which in turn contains individual documents that conceptionally would map back to a "data frame row" when reading/parsing the JSON in R. How can I ensure that all data frames are casted into tibbles when retrieving data from the database? Desired result for example data below Desired result query_res$levelOne <- query_res$levelOne %>% tibble::as_tibble() query_res$levelOne$levelTwo <- query_res

Ensure that data frames become tibbles when reading MongoDB data with {mongolite}

我与影子孤独终老i 提交于 2020-01-16 08:12:09
问题 I have to deal with JSON documents that contain nested documents and at some level have an array which in turn contains individual documents that conceptionally would map back to a "data frame row" when reading/parsing the JSON in R. How can I ensure that all data frames are casted into tibbles when retrieving data from the database? Desired result for example data below Desired result query_res$levelOne <- query_res$levelOne %>% tibble::as_tibble() query_res$levelOne$levelTwo <- query_res

Trying to turn a data frame into hierarchical json array using jsonlite in r

大兔子大兔子 提交于 2020-01-11 10:04:10
问题 I'm trying to get my super-simple data frame into something a little more useful - a json array in this case. My data looks like | V1 | V2 | V3 | V4 | V5 | |-----------|-----------|-----------|-----------|-----------| | 717374788 | 694405490 | 606978836 | 578345907 | 555450273 | | 429700970 | 420694891 | 420694211 | 420792447 | 420670045 | and I want it to look like [ { "V1": { "id": 717374788 }, "results": [ { "id": 694405490 }, { "id": 606978836 }, { "id": 578345907 }, { "id": 555450273 } ]

Trying to turn a data frame into hierarchical json array using jsonlite in r

为君一笑 提交于 2020-01-11 10:03:52
问题 I'm trying to get my super-simple data frame into something a little more useful - a json array in this case. My data looks like | V1 | V2 | V3 | V4 | V5 | |-----------|-----------|-----------|-----------|-----------| | 717374788 | 694405490 | 606978836 | 578345907 | 555450273 | | 429700970 | 420694891 | 420694211 | 420792447 | 420670045 | and I want it to look like [ { "V1": { "id": 717374788 }, "results": [ { "id": 694405490 }, { "id": 606978836 }, { "id": 578345907 }, { "id": 555450273 } ]

R jsonlite - fromJSON always returns Error in open.connection?

做~自己de王妃 提交于 2020-01-07 03:11:29
问题 Why do I always get the connection error with fromJSON ? Sometimes it is fine. Most of time it is not. > # Load json and other packages. > library(jsonlite) > > # Live server. > server <- 'http://0.0.0.0:3000' > # Stream 143 > key <- '9p06nngO2pcQM03nIJ71dLXNA1v' > > # Retrieve json data from the data platform via the URLs. > streams <- fromJSON(paste(server, '/output/streams', sep=""), flatten=TRUE) Result: Error in open.connection(con, "rb") : Couldn't connect to server If I try again: >

doing multiple fromJSON queries (jsonlite)

坚强是说给别人听的谎言 提交于 2020-01-06 06:47:08
问题 I'm a newbie R user and couldn't find any answers which I could understand. My objective is to retrieve information from a URL and then convert the information into a data frame for use. install.packages("jsonlite") library(jsonlite) fromJSON("https://developers.onemap.sg/commonapi/search?searchVal=revenue&returnGeom=Y&getAddrDetails=Y&pageNum=1)") #it works x1 <- as.character("https://developers.onemap.sg/commonapi/search?searchVal=revenue&returnGeom=Y&getAddrDetails=Y&pageNum=1)") fromJSON

How do I read multiple JSON structures contained in one file?

半世苍凉 提交于 2019-12-25 07:58:31
问题 I have a .txt file with this structure section1#[{"p": "0.999834", "tag": "MA"},{"p": "1", "tag": "MO"},...etc...}] section1#[{"p": "0.9995", "tag": "NC"},{"p": "1", "tag": "FL"},...etc...}] ... section2#[{"p": "0.9995", "tag": "NC"},{"p": "1", "tag": "FL"},...etc...}] I am trying to read it by using R with the commands library(jsonlite) data <- fromJSON("myfile.txt") But I get this Error in feed_push_parser(readBin(con, raw(), n), reset = TRUE) : lexical error: invalid char in json text.

Struggling to import NZ companies extract into R (json)

左心房为你撑大大i 提交于 2019-12-25 01:09:21
问题 The NZ companies register offers a json file containing all publicly available business info. This file comes in at a whopping 40gb, but there is also a smaller json file (~250mb) containing data on unincorporated entities (sole traders etc). As a warm up excercise I thought i'd have a go importing it into R to get an idea of size, scalability and computational reqs. I'm having alot of trouble importing the smaller json file into R. I've tried jsonlite, RJSONIO, rjson but it appears that the