transform_json_to_dataframe: Transform json to a tidy dataframe Uses 'jsonlite::fromJSON'...

View source: R/scraping-parsing.R

transform_json_to_dataframeR Documentation

Transform json to a tidy dataframe Uses jsonlite::fromJSON together with some map, enframe and unnest_wider to create a tidy tibble/dataframe.

Description

Transform json to a tidy dataframe Uses jsonlite::fromJSON together with some map, enframe and unnest_wider to create a tidy tibble/dataframe.

Usage

transform_json_to_dataframe(json, unnest_type = "long", keep_name = TRUE)

Arguments

json

json string

unnest_type

should the dataframe be wide or long?

keep_name

default: TRUE; tibble::enframe() names resulting cols, decide if name column is needed

Value

dataframe/tibble

Examples

## Not run: 
res <- httr::GET("https://lobid.org/gnd/search?q=preferredName:Max%20Spohr&format=json")
res <- httr::content(res, as = "text")
df_from_json <- transform_json_to_dataframe(res, unnest_type = "wide")

## End(Not run)

cutterkom/kabrutils documentation built on July 3, 2022, 4:04 p.m.