Tag an atomic vector with a single element as class 'scalar'. When output to JSON it will be output as a scalar not a vector

as_scalar(x)

Arguments

x

atomic vector with length = 1

Value

If x is an atomic vector with length = 1, then object is returned with class 'scalar', otherwise object is returned unmodified