Skip to contents

Serializes an R object into an eon-formatted character string. Named lists become maps, unnamed lists become arrays, and R scalars map to their eon equivalents.

Usage

format_eon(x, indent = "\t")

format_eon(x, indent = "\t")

Arguments

x

An R object (named list, unnamed list, or scalar) to serialize.

indent

A string used for each level of indentation. Defaults to a tab.

Value

A character string containing the eon representation.

Examples

format_eon(list(name = 'Alice', age = 30L))
#> [1] "name: \"Alice\"\nage: 30\n"
format_eon(list(scores = list(1L, 2L, 3L)))
#> [1] "scores: [1, 2, 3]\n"
format_eon(list(active = TRUE, ratio = 0.5))
#> [1] "active: true\nratio: 0.5\n"
format_eon(list(name = 'Alice', age = 30L), indent = '  ')
#> [1] "name: \"Alice\"\nage: 30\n"