Format a json object read in via from_json into a string. Importantly, and unlike jsonlite::toJSON this does not work for arbitrary R objects.

to_json(x)

Arguments

x

A json object to convert

Value

A string

See also

from_json, which does the inverse transformation

Examples

# Lossless json -> R -> json roundtrip of arrays:
tinyjson::to_json(tinyjson::from_json('1'))
#> [1] "1"
tinyjson::to_json(tinyjson::from_json('[1]'))
#> [1] "[1]"
tinyjson::to_json(tinyjson::from_json('[1, 2, 3, 4]'))
#> [1] "[1,2,3,4]"