{jsonify} is great, but I struggle to use it as a mediator for communication with some external APIs due to one missing feature: element-level control of the unbox parameter (in to_json()).
A third-party API might expect this object:
{
"unboxed_prop": "foo",
"boxed_prop": ["variable", "length", "array"]
}
With {jsonlite}, we'd coerce the corresponding R object to something like:
x <- some_data_here() ## may return a vector of length 0, 1, or more
list(
unboxed_prop = "foo",
boxed_prop = I(x) ## 'protect' the value here with I()/AsIs
) |>
jsonlite::toJSON(auto_unbox = TRUE)
With I(x), boxed_prop is guaranteed to be JSON-encoded as an array regardless of length(x).
Is something like this possible with {jsonify}?
{jsonify} is great, but I struggle to use it as a mediator for communication with some external APIs due to one missing feature: element-level control of the
unboxparameter (into_json()).A third-party API might expect this object:
{ "unboxed_prop": "foo", "boxed_prop": ["variable", "length", "array"] }With {jsonlite}, we'd coerce the corresponding R object to something like:
With
I(x),boxed_propis guaranteed to be JSON-encoded as an array regardless oflength(x).Is something like this possible with {jsonify}?