| 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 |
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.
format_eon(x, indent = "\t") format_eon(x, indent = "\t")format_eon(x, indent = "\t") format_eon(x, indent = "\t")
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. |
A character string containing the eon representation.
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 = ' ')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 = ' ')
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.
parse_eon(x) parse_eon(x)parse_eon(x) parse_eon(x)
x |
A character string containing eon-formatted text. |
An R object (named list, unnamed list, or scalar) representing the eon value.
parse_eon('name: "Alice"\nage: 30') parse_eon('scores: [1, 2, 3]') parse_eon('x: true') parse_eon('x: +inf')parse_eon('name: "Alice"\nage: 30') parse_eon('scores: [1, 2, 3]') parse_eon('x: true') parse_eon('x: +inf')
Reads an eon file from disk and parses it into the corresponding R representation.
read_eon(path) read_eon(path)read_eon(path) read_eon(path)
path |
Path to an eon file. |
An R object representing the eon file's contents.
tmp <- tempfile(fileext = '.eon') write_eon(list(x = 1L, y = 'hello'), tmp) read_eon(tmp)tmp <- tempfile(fileext = '.eon') write_eon(list(x = 1L, y = 'hello'), tmp) read_eon(tmp)
Parses and re-serializes an eon string, normalizing whitespace and style without changing the data.
reformat_eon(x, indent = "\t") reformat_eon(x, indent = "\t")reformat_eon(x, indent = "\t") reformat_eon(x, indent = "\t")
x |
A character string containing eon-formatted text. |
indent |
A string used for each level of indentation. Defaults to a tab. |
A reformatted eon string.
reformat_eon('{name:"Alice",age:30}') reformat_eon('{name:"Alice",age:30}', indent = ' ')reformat_eon('{name:"Alice",age:30}') reformat_eon('{name:"Alice",age:30}', indent = ' ')
Returns TRUE if x can be parsed as eon, FALSE otherwise. Unlike
parse_eon(), this never throws an error.
validate_eon(x) validate_eon(x)validate_eon(x) validate_eon(x)
x |
A character string to check. |
A logical scalar.
validate_eon('name: "Alice"\nage: 30') validate_eon('bad: {unclosed')validate_eon('name: "Alice"\nage: 30') validate_eon('bad: {unclosed')
Serializes an R object and writes the eon representation to a file on disk.
write_eon(x, path) write_eon(x, path)write_eon(x, path) write_eon(x, path)
x |
An R object to serialize. |
path |
Path to write the eon file. |
path, invisibly.
tmp <- tempfile(fileext = '.eon') write_eon(list(name = 'Alice', age = 30L), tmp) readLines(tmp)tmp <- tempfile(fileext = '.eon') write_eon(list(name = 'Alice', age = 30L), tmp) readLines(tmp)