Learn R Programming

toml (version 1.0.0)

toml: Parse or Edit TOML text

Description

The edit_toml() function modifies values in a TOML text while retaining the order, comments, and whitespace. Use read_toml() and write_toml() to convert between TOML text and R lists.

Usage

read_toml(file, as_json = FALSE)

parse_toml(toml, as_json = FALSE)

write_toml(x, auto_unbox = TRUE)

edit_toml(toml, field, value)

Value

parse_toml() returns a list and edit_toml() returns the modified TOML text.

Arguments

file

path to file with toml text

as_json

return output as json string instead of R list

toml

string

x

vector or json string to convert to TOML

auto_unbox

convert atomic vectors of length 1 as scalars in TOML, unless they are wrapped in I(). See also jsonlite::toJSON.

field

name of field to change, for example package.version.

value

new value of field to set.

References

toml-edit-js examples

Examples

Run this code
toml <- readLines('https://raw.githubusercontent.com/posit-dev/air/refs/heads/main/Cargo.toml')
toml <- edit_toml(toml, 'workspace.package.rust-version', '1.84')
toml <- edit_toml(toml, 'workspace.dependencies.bla', list(path = "./yolo", rev = "123"))

Run the code above in your browser using DataLab