Skip to contents

This is a thin wrapper for jsonlite::unbox. It stops jsonlite from representing single character, numeric, logical, etc. items as arrays.

Usage

prep_atomic(x)

Arguments

x

vector

Value

an unboxed dataframe with 1 row

Details

This is useful when a property or definition is of type string, number, logical and of length 1.

Examples


x <- 1

# values in x are stored in an array
x|>
jsonlite::toJSON()
#> [1] 
 # output is [1]

# values in x are NOT stored in an array (no square brackets)
prep_atomic(x) |>
  jsonlite::toJSON()
#> 1 
# output is 1