Package 'reon'

Title: Read and Write 'eon' Configuration Files
Description: Parse, create, and write configuration files in the 'eon' format <https://github.com/emilk/eon>. 'eon' is a human-friendly configuration format with optional commas, unquoted identifier keys, and support for comments.
Authors: Christopher T. Kenny [aut, cre] (ORCID: <https://orcid.org/0000-0002-9386-6860>)
Maintainer: Christopher T. Kenny <[email protected]>
License: MIT + file LICENSE
Version: 0.0.0.9000
Built: 2026-05-09 17:54:07 UTC
Source: https://github.com/christopherkenny/reon

Help Index


Convert an R object to an eon-formatted string.

Description

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))
format_eon(list(scores = list(1L, 2L, 3L)))
format_eon(list(active = TRUE, ratio = 0.5))
format_eon(list(name = 'Alice', age = 30L), indent = '  ')

Parse an eon-formatted string into an R object.

Description

Converts an eon-formatted character string into the corresponding R representation. Maps, lists, and scalars are returned as named lists, unnamed lists, and R scalars respectively.

Usage

parse_eon(x)

parse_eon(x)

Arguments

x

A character string containing eon-formatted text.

Value

An R object (named list, unnamed list, or scalar) representing the eon value.

Examples

parse_eon('name: "Alice"\nage: 30')
parse_eon('scores: [1, 2, 3]')
parse_eon('x: true')
parse_eon('x: +inf')

Read an eon file and return its contents as an R object.

Description

Reads an eon file from disk and parses it into the corresponding R representation.

Usage

read_eon(path)

read_eon(path)

Arguments

path

Path to an eon file.

Value

An R object representing the eon file's contents.

Examples

tmp <- tempfile(fileext = '.eon')
write_eon(list(x = 1L, y = 'hello'), tmp)
read_eon(tmp)

Reformat an eon-formatted string.

Description

Parses and re-serializes an eon string, normalizing whitespace and style without changing the data.

Usage

reformat_eon(x, indent = "\t")

reformat_eon(x, indent = "\t")

Arguments

x

A character string containing eon-formatted text.

indent

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

Value

A reformatted eon string.

Examples

reformat_eon('{name:"Alice",age:30}')
reformat_eon('{name:"Alice",age:30}', indent = '  ')

Check whether a string is valid eon.

Description

Returns TRUE if x can be parsed as eon, FALSE otherwise. Unlike parse_eon(), this never throws an error.

Usage

validate_eon(x)

validate_eon(x)

Arguments

x

A character string to check.

Value

A logical scalar.

Examples

validate_eon('name: "Alice"\nage: 30')
validate_eon('bad: {unclosed')

Write an R object to an eon file.

Description

Serializes an R object and writes the eon representation to a file on disk.

Usage

write_eon(x, path)

write_eon(x, path)

Arguments

x

An R object to serialize.

path

Path to write the eon file.

Value

path, invisibly.

Examples

tmp <- tempfile(fileext = '.eon')
write_eon(list(name = 'Alice', age = 30L), tmp)
readLines(tmp)