Skip to contents

These functions cover a large area of potential response body formats. They are all registered to their standard mime type but users may want to use them to register them to alternative types if they know it makes sense.

Usage

format_csv(...)

format_tsv(...)

format_rds(version = "3", ascii = FALSE, ...)

format_geojson(...)

format_feather(...)

format_parquet(...)

format_yaml(...)

format_htmlwidget(...)

format_format(..., sep = "\n")

format_print(..., sep = "\n")

format_cat(..., sep = "\n")

format_unboxed(...)

format_png(...)

format_jpeg(...)

format_tiff(...)

format_svg(...)

format_bmp(...)

format_pdf(...)

Arguments

...

Further argument passed on to the internal formatting function. See Details for information on which function handles the formatting internally in each serializer

version

the workspace format version to use. NULL specifies the current default version (3). The only other supported value is 2, the default from R 1.4.0 to R 3.5.0.

ascii

a logical. If TRUE or NA, an ASCII representation is written; otherwise (default) a binary one. See also the comments in the help for save.

sep

The separator between multiple elements

Value

A function accepting the response body

Provided serializers

  • format_csv() uses readr::format_csv() for formatting. It is registered as "csv" to the mime type text/csv

  • format_tsv() uses readr::format_tsv() for formatting. It is registered as "tsv" to the mime type text/tsv

  • format_rds() uses serialize() for formatting. It is registered as "rds" to the mime type application/rds

  • format_geojson() uses geojsonsf::sfc_geojson() or geojsonsf::sf_geojson() for formatting depending on the class of the response body. It is registered as "geojson" to the mime type application/geo+json

  • format_feather() uses arrow::write_feather() for formatting. It is registered as "feather" to the mime type application/vnd.apache.arrow.file

  • format_parquet() uses nanoparquet::write_parquet() for formatting. It is registered as "parquet" to the mime type application/vnd.apache.parquet

  • format_yaml() uses yaml::as.yaml() for formatting. It is registered as "yaml" to the mime type text/yaml

  • format_htmlwidget() uses htmlwidgets::saveWidget() for formatting. It is registered as "htmlwidget" to the mime type text/html

  • format_format() uses format() for formatting. It is registered as "format" to the mime type text/plain

  • format_print() uses print() for formatting. It is registered as "print" to the mime type text/plain

  • format_cat() uses cat() for formatting. It is registered as "cat" to the mime type text/plain

  • format_unboxed() uses reqres::format_json() with auto_unbox = TRUE for formatting. It is registered as "unboxedJSON" to the mime type application/json

Additional registered serializers

Provided graphics serializers

Serializing graphic output is special because it requires operations before and after the handler is executed. Further, handlers creating graphics are expected to do so through side-effects (ie. call to graphics rendering) or by returning a ggplot2 object. If you want to create your own graphics serializer you should use device_formatter() for constructing it.

  • format_png() uses ragg::agg_png() for rendering. It is registered as "png" to the mime type image/png

  • format_jpeg() uses ragg::agg_jpeg() for rendering. It is registered as "jpeg" to the mime type image/jpeg

  • format_tiff() uses ragg::agg_tiff() for rendering. It is registered as "tiff" to the mime type image/tiff

  • format_svg() uses svglite::svglite() for rendering. It is registered as "svg" to the mime type image/svg+xml

  • format_bmp() uses grDevices::bmp() for rendering. It is registered as "bmp" to the mime type image/bmp

  • format_pdf() uses grDevices::pdf() for rendering. It is registered as "pdf" to the mime type application/pdf