{"id":14069023,"url":"https://github.com/Miachol/configr","last_synced_at":"2025-07-30T05:31:01.377Z","repository":{"id":56936170,"uuid":"78641377","full_name":"Miachol/configr","owner":"Miachol","description":"Implements the JSON, INI, YAML and TOML parser,  for R setting and writing of configuration file.","archived":false,"fork":false,"pushed_at":"2023-07-19T08:24:35.000Z","size":106,"stargazers_count":58,"open_issues_count":4,"forks_count":7,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-07-07T06:04:27.584Z","etag":null,"topics":["configparser","configuration-file","cran","ini","json","r","r-package","toml","yaml"],"latest_commit_sha":null,"homepage":"","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/Miachol.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","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}},"created_at":"2017-01-11T13:25:34.000Z","updated_at":"2025-06-02T20:11:14.000Z","dependencies_parsed_at":"2024-02-24T13:59:25.702Z","dependency_job_id":null,"html_url":"https://github.com/Miachol/configr","commit_stats":{"total_commits":41,"total_committers":2,"mean_commits":20.5,"dds":"0.024390243902439046","last_synced_commit":"8abe8ff79195c46e7a5c2d72d30b00c604cb9ef2"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/Miachol/configr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miachol%2Fconfigr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miachol%2Fconfigr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miachol%2Fconfigr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miachol%2Fconfigr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Miachol","download_url":"https://codeload.github.com/Miachol/configr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miachol%2Fconfigr/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267815187,"owners_count":24148356,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["configparser","configuration-file","cran","ini","json","r","r-package","toml","yaml"],"created_at":"2024-08-13T07:06:32.998Z","updated_at":"2025-07-30T05:31:01.094Z","avatar_url":"https://github.com/Miachol.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"# [![Build Status](https://travis-ci.org/Miachol/configr.svg)](https://travis-ci.org/Miachol/configr) [![CRAN](http://www.r-pkg.org/badges/version/configr)](https://cran.r-project.org/package=configr) [![Downloads](http://cranlogs.r-pkg.org/badges/configr?color=brightgreen)](http://www.r-pkg.org/pkg/configr) [![codecov](https://codecov.io/github/Miachol/configr/branch/master/graphs/badge.svg)](https://codecov.io/github/Miachol/configr) \n\nconfigr package\n==============\n\nThe R package '[configr](https://github.com/Miachol/configr)' implements the\n'[JSON](https://CRAN.R-project.org/package=jsonlite)', \n'[INI](https://CRAN.R-project.org/package=ini)', \n'[YAML](https://CRAN.R-project.org/package=yaml)', \nand '[TOML](https://CRAN.R-project.org/package=RcppTOML)' parser for R setting and writing of configuration file.\n\n# Introduction \n\nThe configuration file is required for several projects. It can be used to manage and set the project environment variables. The readability and maneuverability of configuration files, from INI/XML/JSON/YAML to TOML, have been improved in the past few years.  Several such parsers were created in the R language. Though it is more efficient than before, we still need to utilize different functions to parse configuration files with different formats. However, in most cases, we only just want to read it and regardless of the format. Using a single function to read or/and write such configuration files is more comfortable.\n\n[configr](https://github.com/Miachol/configr) provides a more simple way to parse and generate the diverse configuration files including JSON/INI/YAML/TOML files. The `configr` is similar to that of package '[config](https://CRAN.R-project.org/package=config)'. Vignettes can be found in [usage-of-configr](https://life2cloud.com/en/2017/07/usage-of-configr/) and [configuration-filetypes](https://life2cloud.com/en/2017/07/configuration-filetypes/).\n\n# Installation\n\n## CRAN\n``` r\n# Install this package directly from CRAN by running (from within R):\ninstall.packages('configr')\n```\n\n## Github\n``` r\n# Install the cutting edge development version from GitHub:\n# install.packages(\"devtools\")\ndevtools::install_github(\"Miachol/configr\")\n```\n\n## Zip/Tarball\n\n1. Download the appropriate zip file or tar.gz file from Github\n2. Unzip the file and change directories into the configr directory\n3. Run `R CMD INSTALL pkg`\n\n# Basic usage\n\n```r\nlibrary(configr)\n\n# Demo files\nconfig.json \u003c- system.file('extdata', 'config.json', package='configr')\nconfig.ini \u003c- system.file('extdata', 'config.ini', package='configr')\nconfig.yaml \u003c- system.file('extdata', 'config.yaml', package='configr')\nconfig.toml \u003c- system.file('extdata', 'config.toml', package='configr')\nconfig.glob \u003c- system.file('extdata', 'config.global.toml', package='configr')\n\n# Check the type of configuration file\nis.json \u003c- is.json.file(file = config.json)\nis.ini \u003c- is.ini.file(file = config.ini)\nis.yaml \u003c- is.yaml.file(file = config.yaml)\nis.toml \u003c- is.toml.file(file = config.toml)\n\n# Check the type of configuration file (Debug mode)\nis.json \u003c- is.json.file(file = config.yaml, json.file.debug = T)\nis.ini \u003c- is.ini.file(file = config.json, ini.file.debug = T)\nis.yaml \u003c- is.yaml.file(file = config.yaml, yaml.file.debug = T)\nis.toml \u003c- is.toml.file(file = config.toml, toml.file.debug = T)\n\n# Query the type of configuration file\njson \u003c- get.config.type(file = config.json) \nini \u003c- get.config.type(file = config.ini) \nyaml \u003c- get.config.type(file = config.yaml) \ntoml \u003c- get.config.type(file = config.toml) \n\n# Read the whole configuration file\njson.list \u003c- read.config(file = config.json)\nini.list \u003c- read.config(file = config.ini)\nyaml.list \u003c- read.config(file = config.yaml)\ntoml.list \u003c- read.config(file = config.toml) \n\n# Read specific section of configuration file (default is 'default' section)\n# Configuration type, section, and path were added to the parsed object\nconfig.json.obj \u003c- eval.config(file = config.json)\nconfig.ini.obj \u003c- eval.config(file = config.ini)\nconfig.yaml.obj \u003c- eval.config(file = config.yaml)\nconfig.toml.obj \u003c- eval.config(file = config.toml)\n\n# Query all section names\njson.sections \u003c- eval.config.sections(file = config.json)\nini.sections \u003c- eval.config.sections(file = config.ini)\nyaml.sections \u003c- eval.config.sections(file = config.yaml)\ntoml.sections \u003c- eval.config.sections(file = config.toml)\n\n# Merge multiple sections, default is all\n# Reduce a layer of configuration file\njson.config.all \u003c- eval.config.merge(file = config.json)\nini.config.all \u003c- eval.config.merge(file = config.ini)\nyaml.config.all \u003c- eval.config.merge(file = config.yaml)\ntoml.config.all \u003c- eval.config.merge(file = config.toml)\n\n# Parse string to configuration list object\njson_string \u003c- '{\"city\" : \"Z\\\\u00FCrich\"}\\n'\nyaml_string \u003c- 'foo: 123\\n'\njson_config \u003c- str2config(json_string)\nyaml_config \u003c- str2config(yaml_string)\n\n# Download and parse files from remote websits\nlinks \u003c- c('https://raw.githubusercontent.com/JhuangLab/BioInstaller/master/inst/extdata/config/db/db_annovar.toml', \n           'https://raw.githubusercontent.com/JhuangLab/BioInstaller/master/inst/extdata/config/db/db_main.toml')\nfetch.config(links)\n\n# Convert YAML format to JSON format\nconvert.config(file = config.yaml, out.file = tempfile(, fileext = \".json\"), \n  convert.to = \"JSON\")\n\n# Write JSON format file\nlist.test \u003c- list(a=c(123,456))\nout.fn \u003c- sprintf(\"%s/test.json\", tempdir())\n\nwrite.config(config.dat = list.test, file.path = out.fn, \n  write.type = \"json\")\n\n# Write JSON format file with 2 indent\nwrite.config(config.dat = list.test, file.path = out.fn, \n  write.type = \"json\", indent = 2)\n\n# Write YAML format file\nout.fn \u003c- sprintf(\"%s/test.yaml\", tempdir())\nwrite.config(config.dat = list.test, file.path = out.fn, \n  write.type = \"yaml\")\n# Write YAML format file with 4 indent\nwrite.config(config.dat = list.test, file.path = out.fn, \n  write.type = \"yaml\", indent = 4)\n\n# Write TOML format file\n# !! You need install python and toml package\n# pip install toml\nout.fn \u003c- sprintf(\"%s/test.toml\", tempdir())\nwrite.config(config.dat = list.test, file.path = out.fn, \n  write.type = \"toml\")\n\nout.fn \u003c- sprintf(\"%s/test.ini\", tempdir())\n\n# Write INI format file\nwrite.config(config.dat = list.test, file.path = out.fn, \n  write.type = \"ini\")\n\n# Write INI format file. It only includes given sections.\nwrite.config(config.dat = list.test, file.path = out.fn, sections = \"a\",\n  write.type = \"ini\")\n\n# Demo of extended parse functions\n# \n# Read raw file by jsonlite, yaml, INI and RcppTOML packages\nconfig.1 \u003c- read.config(file = config.json)\nother.config \u003c- system.file('extdata', 'config.other.yaml', package='configr')\n\n# Replace any string \"{{debug}}\" and \"{{debug2}}\" to \"self\" and \"self2\" respectively\nconfig.2 \u003c- read.config(file = config.json, \n  extra.list = list(debug = \"self\", debug2 = \"self2\"))\n\n# Replace any string \"{{debug}}\" and \"{{debug2}}\" to \"self\" and \"self2\" respectively\n# Then replace {{key:yes_flag}} to the value of other.config key's yes_flag and no_flag\nconfig.3 \u003c- read.config(file = config.json, \n  extra.list = list(debug = \"self\", debug2 = \"self2\"), \n  other.config = other.config)\n\n# Replace any string \"{{debug}}\" and \"{{debug2}}\" to \"self\" and \"self2\" respectively\n# Then replace {{key:yes_flag}} to value in other.config key's yes_flag and no_flag\n# Then replace @\u003e@ Sys.Date() @\u003c@ to R command result ...\nconfig.4 \u003c- read.config(file = config.json, \n  extra.list = list(debug = \"self\", debug2 = \"self2\"), \n  other.config = other.config, rcmd.parse = T)\n\nconfig.5 \u003c- parse.extra(config.1, \n  extra.list = list(debug = \"self\", debug2 = \"self2\"), \n  other.config = other.config, rcmd.parse = T)\n  \n# Replace any items contained string \"{{debug}}\" to \"self\" and \"debug2\" to \"self2\"\n# Then replace {{key:yes_flag}} to value in other.config key's yes_flag and no_flag\n# Then replace @\u003e@ Sys.Date() @\u003c@ to R command executed result ...\n# Then replace #\u003e#echo bash#\u003c# to system() executed result\nconfig.6 \u003c- parse.extra(config.1, \n  extra.list = list(debug = \"self\", debug2 = \"self2\", yes = \"1\", no = \"0\"), \n  other.config = other.config, rcmd.parse = T, bash.parse = T)\n\n# Use glue() to parse \"{value or R CMD}\"\n# It will changes the length of a vector if returned value is a vector\nraw \u003c- c(\"a\", \"!!glue{1:5}\", \"c\")\nlist.raw \u003c- list(glue = raw, nochange = 1:10)\nparsed \u003c- parse.extra(list.raw, glue.parse = TRUE, glue.flag = \"!!glue\")\nexpect.parsed.1 \u003c- c(\"a\", \"1\", \"2\", \"3\", \"4\", \"5\", \"c\")\nexpect.parsed.2 \u003c- list(glue = expect.parsed.1, nochange = 1:10)\n\n\n# Global vars parse (new feature in v0.3.4)\n# \nconfig_no_parsed_global \u003c- read.config(config.glob, global.vars.field = NULL)\nconfig_parsed \u003c- read.config(config.glob)\n\n# Delete a section in a configuration object\nconfig.partial \u003c- config.sections.del(config.1, \"default\")\n```\n\nIf you want to access external helps about configurations format or other related information,\nYou can use `configr::config.help()` do this. It will return a dataframe contains all helps or open \na browser, such as Chrome, to access the corresponding URL.\n\n```r\n# Show all help urls stored in configr\nconfig.help()\n# Open the url in browser\nconfig.help('toml_stackoverflow_search')\n# Or use the row number to access\nconfig.help(23)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMiachol%2Fconfigr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMiachol%2Fconfigr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMiachol%2Fconfigr/lists"}