{"id":28063717,"url":"https://github.com/extendr/tomledit","last_synced_at":"2026-03-07T13:31:23.491Z","repository":{"id":276393751,"uuid":"929162686","full_name":"extendr/tomledit","owner":"extendr","description":"Parse, Read, and Edit TOML ","archived":false,"fork":false,"pushed_at":"2026-02-10T16:27:19.000Z","size":10792,"stargazers_count":12,"open_issues_count":4,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-19T16:16:06.202Z","etag":null,"topics":["extendr","rstats","toml"],"latest_commit_sha":null,"homepage":"https://extendr.github.io/tomledit/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/extendr.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-07T23:24:52.000Z","updated_at":"2026-02-10T16:23:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"65e89840-9404-4e59-a344-ecf1f39b30de","html_url":"https://github.com/extendr/tomledit","commit_stats":null,"previous_names":["josiahparry/tomledit","extendr/tomledit"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/extendr/tomledit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extendr%2Ftomledit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extendr%2Ftomledit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extendr%2Ftomledit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extendr%2Ftomledit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/extendr","download_url":"https://codeload.github.com/extendr/tomledit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extendr%2Ftomledit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30215589,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T13:25:55.541Z","status":"ssl_error","status_checked_at":"2026-03-07T13:25:38.596Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["extendr","rstats","toml"],"created_at":"2025-05-12T12:18:56.555Z","updated_at":"2026-03-07T13:31:23.434Z","avatar_url":"https://github.com/extendr.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n# tomledit\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/extendr/tomledit/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/extendr/tomledit/actions/workflows/R-CMD-check.yaml)\n[![extendr](https://img.shields.io/badge/extendr-%5E0.7.1-276DC2)](https://extendr.github.io/extendr/extendr_api/)\n\u003c!-- badges: end --\u003e\n\nCreate or edit TOML documents from R using `tomledit`.\n\n`tomledit` is written in Rust using\n[extendr](https://extendr.github.io/) and the\n[`toml_edit`](https://docs.rs/toml_edit/) crate.\n\n## Installation\n\nInstall the package from CRAN using\n\n``` r\ninstall.packages(\"tomledit\")\n```\n\nor, install the development version using\n\n``` r\nremotes::install_github(\"extendr/tomledit\")\n```\n\n## Usage\n\nTOML can be created using either the `as_toml()` or `toml()` functions.\n\nUse `as_toml()` to convert a list to TOML:\n\n``` r\nlibrary(tomledit)\n\nas_toml(\n  list(\n    person = list(age = 30L, name = \"Wilma\")\n  )\n)\n```\n\n    \u003cToml\u003e\n    [person]\n    age = 30\n    name = \"Wilma\"\n\nCreate TOML directly by passing key values to `toml()`:\n\n``` r\nx \u003c- toml(person = list(age = 30L, name = \"Wilma\"))\nx\n```\n\n    \u003cToml\u003e\n    [person]\n    age = 30\n    name = \"Wilma\"\n\nOr, parse a string as TOML while preserving comments:\n\n``` r\nraw_toml \u003c- '# Top-level table begins.\nname = \"Fido\"\nbreed = \"pug\"\n\n# Top-level table ends.\n[owner]\nname = \"Regina Dogman\"\nmember_since = 1999-08-04'\n\nx \u003c- parse_toml(raw_toml)\nx\n```\n\n    \u003cToml\u003e\n    # Top-level table begins.\n    name = \"Fido\"\n    breed = \"pug\"\n\n    # Top-level table ends.\n    [owner]\n    name = \"Regina Dogman\"\n    member_since = 1999-08-04\n\nWrite a `Toml` object to a file using `write_toml()`.\n\n``` r\ntmp \u003c- tempfile(fileext = \".toml\")\n\nwrite_toml(x, tmp)\n```\n\nRead a TOML file using `read_toml()`.\n\n``` r\nread_toml(tmp)\n```\n\n    \u003cToml\u003e\n    # Top-level table begins.\n    name = \"Fido\"\n    breed = \"pug\"\n\n    # Top-level table ends.\n    [owner]\n    name = \"Regina Dogman\"\n    member_since = 1999-08-04\n\nItems can be inserted into a `Toml` document using `insert_items()`\n\n``` r\ny \u003c- x |\u003e \n  insert_items(\n    date = Sys.Date(),\n    date_parts = list(year = 2015L, month = \"February\", day = 7L)\n  )\n\ny\n```\n\n    \u003cToml\u003e\n    # Top-level table begins.\n    name = \"Fido\"\n    breed = \"pug\"\n    date = 2025-03-03\n\n    # Top-level table ends.\n    [owner]\n    name = \"Regina Dogman\"\n    member_since = 1999-08-04\n\n    [date_parts]\n    year = 2015\n    month = \"February\"\n    day = 7\n\nOr items can be removed as well using `remove_items()`\n\n``` r\nremove_items(y, c(\"date\", \"date_parts\"))\n```\n\n    \u003cToml\u003e\n    # Top-level table begins.\n    name = \"Fido\"\n    breed = \"pug\"\n\n    # Top-level table ends.\n    [owner]\n    name = \"Regina Dogman\"\n    member_since = 1999-08-04\n\nIndividual items can be fetched recursively from the `Toml` document.\n\n``` r\nget_item(y, c(\"date_parts\", \"month\"))\n```\n\n    [1] \"February\"\n\nOr the entire `Toml` document can be converted to a list. Note, though,\nthat it is not always possible to perform a perfect round trip of R\nobjects and TOML.\n\n``` r\nfrom_toml(y)\n```\n\n    $name\n    [1] \"Fido\"\n\n    $breed\n    [1] \"pug\"\n\n    $owner\n    $owner$name\n    [1] \"Regina Dogman\"\n\n    $owner$member_since\n    [1] \"1999-08-04\"\n\n\n    $date\n    [1] \"2025-03-03\"\n\n    $date_parts\n    $date_parts$year\n    [1] 2015\n\n    $date_parts$month\n    [1] \"February\"\n\n    $date_parts$day\n    [1] 7\n\n## Array of Tables\n\nBy default `tomledit` converts `data.frame` objects to an [array of\ntables](https://toml.io/en/v1.0.0#array-of-tables).\n\n``` r\ntoml(iris = iris[1:3,])\n```\n\n    \u003cToml\u003e\n    [[iris]]\n    \"Sepal.Length\" = 5.1\n    \"Sepal.Width\" = 3.5\n    \"Petal.Length\" = 1.4\n    \"Petal.Width\" = 0.2\n    Species = \"setosa\"\n\n    [[iris]]\n    \"Sepal.Length\" = 4.9\n    \"Sepal.Width\" = 3.0\n    \"Petal.Length\" = 1.4\n    \"Petal.Width\" = 0.2\n    Species = \"setosa\"\n\n    [[iris]]\n    \"Sepal.Length\" = 4.7\n    \"Sepal.Width\" = 3.2\n    \"Petal.Length\" = 1.3\n    \"Petal.Width\" = 0.2\n    Species = \"setosa\"\n\nThis is the default behavior as it is most consistent with TOML files\nthat are encountered in the wild. To create a single table from a\n`data.frame`, set the argument `df_as_array = FALSE`.\n\n``` r\ntoml(\n  iris = iris[1:3,],\n  df_as_array = FALSE\n)\n```\n\n    \u003cToml\u003e\n    [iris]\n    \"Sepal.Length\" = [5.1, 4.9, 4.7]\n    \"Sepal.Width\" = [3.5, 3.0, 3.2]\n    \"Petal.Length\" = [1.4, 1.4, 1.3]\n    \"Petal.Width\" = [0.2, 0.2, 0.2]\n    Species = [\"setosa\", \"setosa\", \"setosa\"]\n\n## Missing Values\n\nOne reason why array of tables are recommended for `data.frame`s is\nbecause there is no concept of a missing or null value in TOML.\n\nTake the following example:\n\n``` r\nx \u003c- data.frame(\n  x = c(1L, NA, 2L),\n  y = letters[1:3]\n) \n```\n\nNotice that when this `data.frame` is serialized to TOML the missing `x`\nvalue is omitted:\n\n``` r\ntoml(table = x)\n```\n\n    \u003cToml\u003e\n    [[table]]\n    x = 1\n    y = \"a\"\n\n    [[table]]\n    y = \"b\"\n\n    [[table]]\n    x = 2\n    y = \"c\"\n\nWhereas when serializing to a single table the `x` array has 2 elements\nwhereas the `y` element has 3 elements.\n\n``` r\ntoml(table = x, df_as_array = FALSE)\n```\n\n    \u003cToml\u003e\n    [table]\n    x = [1, 2]\n    y = [\"a\", \"b\", \"c\"]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fextendr%2Ftomledit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fextendr%2Ftomledit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fextendr%2Ftomledit/lists"}