R/pxweb_as_json.R

Defines functions pxweb_as_json.pxweb_query pxweb_as_json

Documented in pxweb_as_json pxweb_as_json.pxweb_query

#' Convert object to json
#'
#' @param x an object to convert.
#'
#' @keywords internal
pxweb_as_json <- function(x) {
  UseMethod("pxweb_as_json")
}

#' @rdname pxweb_as_json
#' @keywords internal
pxweb_as_json.pxweb_query <- function(x) {
  for (i in seq_along(x$query)) {
    x$query[[i]]$selection$values <- as.list(x$query[[i]]$selection$values)
  }
  jsonlite::toJSON(x, auto_unbox = TRUE)
}

Try the pxweb package in your browser

Any scripts or data that you put into this service are public.

pxweb documentation built on May 29, 2024, 2:28 a.m.