json_safely: Safely Serialize to JSON String

View source: R/utils_json.R

json_safelyR Documentation

Safely Serialize to JSON String

Description

Converts an R object to a valid JSON string. Returns "{}" on failure or for NULL/empty inputs.

Usage

json_safely(x)

Arguments

x

An R object to serialize.

Value

A single character string containing valid JSON.

Examples

json_safely(list(a = 1, b = "hello"))
json_safely(NULL)


r4subcore documentation built on Feb. 20, 2026, 5:09 p.m.