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
orNA
, an ASCII representation is written; otherwise (default) a binary one. See also the comments in the help forsave
.- sep
The separator between multiple elements
Provided serializers
format_csv()
usesreadr::format_csv()
for formatting. It is registered as"csv"
to the mime typetext/csv
format_tsv()
usesreadr::format_tsv()
for formatting. It is registered as"tsv"
to the mime typetext/tsv
format_rds()
usesserialize()
for formatting. It is registered as"rds"
to the mime typeapplication/rds
format_geojson()
usesgeojsonsf::sfc_geojson()
orgeojsonsf::sf_geojson()
for formatting depending on the class of the response body. It is registered as"geojson"
to the mime typeapplication/geo+json
format_feather()
usesarrow::write_feather()
for formatting. It is registered as"feather"
to the mime typeapplication/vnd.apache.arrow.file
format_parquet()
usesnanoparquet::write_parquet()
for formatting. It is registered as"parquet"
to the mime typeapplication/vnd.apache.parquet
format_yaml()
usesyaml::as.yaml()
for formatting. It is registered as"yaml"
to the mime typetext/yaml
format_htmlwidget()
useshtmlwidgets::saveWidget()
for formatting. It is registered as"htmlwidget"
to the mime typetext/html
format_format()
usesformat()
for formatting. It is registered as"format"
to the mime typetext/plain
format_print()
usesprint()
for formatting. It is registered as"print"
to the mime typetext/plain
format_cat()
usescat()
for formatting. It is registered as"cat"
to the mime typetext/plain
format_unboxed()
usesreqres::format_json()
withauto_unbox = TRUE
for formatting. It is registered as"unboxedJSON"
to the mime typeapplication/json
Additional registered serializers
reqres::format_json()
is registered as "json
" to the mime typeapplication/json
reqres::format_html()
is registered as "html
" to the mime typetext/html
reqres::format_xml()
is registered as "xml
" to the mime typetext/xml
reqres::format_plain()
is registered as "text
" to the mime typetext/plain
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()
usesragg::agg_png()
for rendering. It is registered as"png"
to the mime typeimage/png
format_jpeg()
usesragg::agg_jpeg()
for rendering. It is registered as"jpeg"
to the mime typeimage/jpeg
format_tiff()
usesragg::agg_tiff()
for rendering. It is registered as"tiff"
to the mime typeimage/tiff
format_svg()
usessvglite::svglite()
for rendering. It is registered as"svg"
to the mime typeimage/svg+xml
format_bmp()
usesgrDevices::bmp()
for rendering. It is registered as"bmp"
to the mime typeimage/bmp
format_pdf()
usesgrDevices::pdf()
for rendering. It is registered as"pdf"
to the mime typeapplication/pdf