zu_body_json() and zu_resp_json() use zujson by default
(zujson::json_write() and zujson::json_parse()); this replaces it with
anything else, jsonlite included.
Examples
# Any pair of functions will do; a real one would wrap a JSON package,
# e.g. encode = function(x, ...) RcppSimdJson::serialize(x).
old <- zu_set_json_backend(
encode = function(x, ...) sprintf('{"n":%d}', length(x)),
decode = function(txt, ...) list(text = txt)
)
req <- zu_request("POST", "https://api.example.com")
req <- zu_body_json(req, list(1, 2))
rawToChar(req$body)
#> [1] "{\"n\":2}"
zu_set_json_backend(old$encode, old$decode) # restore