{"id":28615588,"url":"https://github.com/ocamlpro/ez_toml","last_synced_at":"2025-06-12T02:09:30.051Z","repository":{"id":192532413,"uuid":"686779261","full_name":"OCamlPro/ez_toml","owner":"OCamlPro","description":"A library to parse and print TOML files","archived":false,"fork":false,"pushed_at":"2024-03-05T14:12:58.000Z","size":3866,"stargazers_count":6,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-03-05T15:30:49.571Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://ocamlpro.github.io/ez_toml/","language":"OCaml","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/OCamlPro.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2023-09-03T22:54:19.000Z","updated_at":"2024-03-05T15:30:50.354Z","dependencies_parsed_at":null,"dependency_job_id":"31d6af47-adaa-418f-94b7-b9ff504ebcdf","html_url":"https://github.com/OCamlPro/ez_toml","commit_stats":null,"previous_names":["ocamlpro/ez_toml"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/OCamlPro/ez_toml","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OCamlPro%2Fez_toml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OCamlPro%2Fez_toml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OCamlPro%2Fez_toml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OCamlPro%2Fez_toml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OCamlPro","download_url":"https://codeload.github.com/OCamlPro/ez_toml/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OCamlPro%2Fez_toml/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259382323,"owners_count":22848843,"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","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":[],"created_at":"2025-06-12T02:09:28.465Z","updated_at":"2025-06-12T02:09:30.034Z","avatar_url":"https://github.com/OCamlPro.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[![Actions Status](https://github.com/ocamlpro/ez_toml/workflows/Main%20Workflow/badge.svg)](https://github.com/ocamlpro/ez_toml/actions)\n[![Release](https://img.shields.io/github/release/ocamlpro/ez_toml.svg)](https://github.com/ocamlpro/ez_toml/releases)\n\n# ez_toml\n\nThis ez_toml library is a small library to read and write files in TOML\nformat. Compared to the toml library, it supports more features (mixed\narrays for example), fixes a few bugs in the printer, and keeps better\ntrack of options order and comments in file.\n\n* Website: https://ocamlpro.github.io/ez_toml\n* General Documentation: https://ocamlpro.github.io/ez_toml/sphinx\n* API Documentation: https://ocamlpro.github.io/ez_toml/doc\n* Sources: https://github.com/ocamlpro/ez_toml\n\n## Basic Example\n\nYou will need to open `Ez_toml.V1`, then you have access to:\n\n* `TOML` submodule: contains all the interesting functions\n* `TOML.Types` submodule: contains all the type declarations\n\nUsually, you should open `TOML.Types` and use qualified names to access\nfunctions in `TOML`.\n\nTo use the following script, just rename it as `top.ml` in the source\ndirectory of `ez_toml`, start `ocaml` and type `#use \"top.ml\";;`:\n\n```ocaml\n#directory \"_opam/lib/ocplib_stuff\";;\n#directory \"_opam/lib/ISO8601\";;\n#directory \"_opam/lib/re\";;\n#directory \"_opam/lib/re/glob\";;\n#directory \"_opam/lib/ez_file\";;\n#directory \"_build/install/default/lib/ez_toml\";;\n(* #directory \"_build/default/src/ez_toml\";;  *)\n\n#load \"unix.cma\";;\n#load \"ocplib_stuff.cma\";;\n#load \"ISO8601.cma\";;\n#load \"re.cma\";;\n#load \"re_glob.cma\";;\n#load \"ez_file.cma\";;\n#load \"ez_toml.cma\";;\n\n\nopen Ez_toml.V1\n\nopen TOML.Types\n\n(* Look up a deeply nested value with a known type. *)\nlet t = TOML.of_string \"\n[settings]\n  [settings.basic]\n    crash_randomly = true\n\" ;;\n\n(*\n  val t : Ez_toml.V1.TOML.Types.node =\n  {node_comment_before = []; node_comment_after = None;\n   node_loc =\n    {file = \"\"; line_begin = 2; line_end = 5; char_begin = 0; char_end = 0};\n   node_format = Any; node_pos = 1; node_value = Table \u003cabstr\u003e;\n   node_name = [\"???\"]}\n*)\n\n(* Look up a deeply nested value with a known type. *)\nlet crash_randomly =\n  TOML.get t  [\"settings\"; \"basic\"; \"crash_randomly\"]\n  |\u003e TOML.extract_bool\n\n(*  val crash_randomly : bool = true *)\n\n(* Update a deeply nested value. *)\n(* This would fail because the key already exists:\n\nlet () =\n  TOML.set t [\"settings\"; \"basic\"; \"crash_randomly\"] (TOML.int 0)\n;;\n\nraises exception 4, Ez_toml.Types.Key_already_exists [\"crash_randomly\"] *)\n\n(* so, We need to silent overriding errors *)\nlet config = { TOML.default_config with\n\t       silent_errors =\n\t         EzCompat.IntSet.add 4 TOML.default_config.silent_errors }\n;;\n\nlet () =\n  TOML.set ~config t [\"settings\"; \"basic\"; \"crash_randomly\"]\n     ~value:(TOML.int 0)\n;;\n\n(* Print it back to a string *)\nlet s = TOML.to_string t\n;;\n\n(* val s : string = \"\\n[settings.basic]\\ncrash_randomly = 0\\n\" *)\n\n```\n\n## Tests example\n\nCheck file `src/toml-check/tests.ml` for another example of simple\naccesses and modifications of the TOML datastructure.\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Focamlpro%2Fez_toml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Focamlpro%2Fez_toml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Focamlpro%2Fez_toml/lists"}