R/fetch_json_as_list.R

Defines functions fetch_json_as_list

Documented in fetch_json_as_list

#' Make a call to the Census API and convert the JSON response to an R list.
#'
#' @inheritParams build_api_url
#'
#' @return a list of items read from json
#' @keywords internal
#'
#' @seealso [build_api_url()]
#' @seealso [jsonlite::read_json()]
fetch_json_as_list <- function(variables,
                               year,
                               for_geo,
                               for_items,
                               survey_type,
                               table_or_survey_code,
                               ...,
                               use_key = TRUE) {
    variables |>
        build_api_url(
            variables = _,
            for_geo = for_geo,
            for_items = for_items,
            year = year,
            survey_type = survey_type,
            table_or_survey_code = table_or_survey_code,
            ...,
            use_key = use_key
        ) |>
        jsonlite::read_json()
}
higherX4Racine/hercacstables documentation built on Jan. 15, 2025, 9:58 p.m.