All Projects → ocaml-toml → To.ml

ocaml-toml / To.ml

Licence: other
OCaml library for TOML

Programming Languages

ocaml
1615 projects

Projects that are alternatives of or similar to To.ml

Dasel
Query, update and convert data structures from the command line. Comparable to jq/yq but supports JSON, TOML, YAML, XML and CSV with zero runtime dependencies.
Stars: ✭ 759 (+1016.18%)
Mutual labels:  config, toml, parser
tomlj
A Java parser for Tom's Obvious, Minimal Language (TOML).
Stars: ✭ 72 (+5.88%)
Mutual labels:  config, toml
transfer
Converts from one encoding to another. Supported formats HCL ⇄ JSON ⇄ YAML⇄TOML⇄XML⇄plist⇄pickle⇄properties ...
Stars: ✭ 70 (+2.94%)
Mutual labels:  config, toml
goconf
Configuration loader in Go
Stars: ✭ 23 (-66.18%)
Mutual labels:  config, toml
tomli
A lil' TOML parser
Stars: ✭ 313 (+360.29%)
Mutual labels:  config, toml
cfg-rs
A Configuration Library for Rust Applications
Stars: ✭ 18 (-73.53%)
Mutual labels:  config, toml
rubric
Linter Config Initializer for Python
Stars: ✭ 21 (-69.12%)
Mutual labels:  config, toml
Gcfg
read INI-style configuration files into Go structs; supports user-defined types and subsections
Stars: ✭ 146 (+114.71%)
Mutual labels:  config, parser
Tomlplusplus
Header-only TOML config file parser and serializer for C++17 (and later!).
Stars: ✭ 403 (+492.65%)
Mutual labels:  toml, parser
Koanf
Light weight, extensible configuration management library for Go. Built in support for JSON, TOML, YAML, env, command line, file, S3 etc. Alternative to viper.
Stars: ✭ 450 (+561.76%)
Mutual labels:  config, toml
Konf
A type-safe cascading configuration library for Kotlin/Java/Android, supporting most configuration formats
Stars: ✭ 225 (+230.88%)
Mutual labels:  config, toml
Config Rs
⚙️ Layered configuration system for Rust applications (with strong support for 12-factor applications).
Stars: ✭ 915 (+1245.59%)
Mutual labels:  config, toml
Config
📝 Go config manage(load,get,set). support JSON, YAML, TOML, INI, HCL, ENV and Flags. Multi file load, data override merge, parse ENV var. Go应用配置加载管理,支持多种格式,多文件加载,远程文件加载,支持数据合并,解析环境变量名
Stars: ✭ 225 (+230.88%)
Mutual labels:  config, toml
climatecontrol
Python library for loading settings and config data from files and environment variables
Stars: ✭ 20 (-70.59%)
Mutual labels:  config, toml
Simple Settings
A simple way to manage your project settings.
Stars: ✭ 165 (+142.65%)
Mutual labels:  config, toml
parse it
A python library for parsing multiple types of config files, envvars & command line arguments that takes the headache out of setting app configurations.
Stars: ✭ 86 (+26.47%)
Mutual labels:  config, toml
Config Lite
A super simple & flexible & useful config module.
Stars: ✭ 78 (+14.71%)
Mutual labels:  config, toml
Toml11
TOML for Modern C++
Stars: ✭ 390 (+473.53%)
Mutual labels:  toml, parser
Strictyaml
Type-safe YAML parser and validator.
Stars: ✭ 836 (+1129.41%)
Mutual labels:  config, parser
Mconfig
MCONFIG is a lightweight Golang library for integrating configs files like (json, yml, toml) and environment variables into one config struct.
Stars: ✭ 28 (-58.82%)
Mutual labels:  config, toml

toml build status coverage percentage

OCaml library for TOML.

Documentation

Have a look at the online documentation. Otherwise, here's a quickstart guide.

Reading TOML data

utop # (* This will return either `Ok $tomltable or `Error $error_with_location *)
let ok_or_error = Toml.Parser.from_string "key=[1,2]";;
val ok_or_error : Toml.Parser.result = `Ok <abstr> 

utop # (* You can use the 'unsafe' combinator to get the result directly, or an
exception if a parsing error occurred *)
let parsed_toml = Toml.Parser.(from_string "key=[1,2]" |> unsafe);;
val parsed_toml : Toml.Types.table = <abstr>

utop # (* Use simple pattern matching to read the value *)
Toml.Types.Table.find (Toml.Min.key "key") parsed_toml;;
- : Toml.Types.value = Toml.Types.TArray (Toml.Types.NodeInt [1; 2])

Writing TOML data

utop # let toml_data = Toml.of_key_values [
    Toml.key "ints", Toml.Types.TArray (Toml.Types.NodeInt [1; 2]);
    Toml.key "string", Toml.Types.TString "string value";
];;
val toml_data : Toml.Types.table = <abstr>

utop # Toml.Printer.string_of_table toml_data;;
- : bytes = "ints = [1, 2]\nstring = \"string value\"\n"

Lenses

Through lenses, it is possible to read/write deeply nested data with ease. The Toml.Lenses module provides partial lenses (that is, lenses returning option types) to manipulate TOML data structures.

utop # let toml_data = Toml.Parser.(from_string "
[this.is.a.deeply.nested.table]
answer=42" |> unsafe);;
val toml_data : Toml.Types.table = <abstr>

utop # Toml.Lenses.(get toml_data (
  key "this" |-- table
  |-- key "is" |-- table
  |-- key "a" |-- table
  |-- key "deeply" |-- table
  |-- key "nested" |-- table
  |-- key "table" |-- table
  |-- key "answer"|-- int ));;
- : int option = Some 42

utop # let maybe_toml_data' = Toml.Lenses.(set 2015 toml_data (
  key "this" |-- table
  |-- key "is" |-- table
  |-- key "a" |-- table
  |-- key "deeply" |-- table
  |-- key "nested" |-- table
  |-- key "table" |-- table
  |-- key "answer"|-- int ));;
val maybe_toml_data' : Toml.Types.table option = Some <abstr>

utop # Toml.Printer.string_of_table toml_data';;
- : bytes = "[this.is.a.deeply.nested.table]\nanswer = 2015\n"

toml_cconv

A second library, toml_cconv for encoding/decoding with cconv can be installed if cconv is present.

toml supports ppx via cconv:

utop # #require "cconv.ppx";;
utop # #require "toml.cconv";;

utop # type t = { ints : int list; string : string } [@@deriving cconv];;
type t = { ints : int list; string : string; }                                                  
val encode : t CConv.Encode.encoder = {CConv.Encode.emit = <fun>}                               
val decode : t CConv.Decode.decoder =
  {CConv.Decode.dec =
    {CConv.Decode.accept_unit = <fun>; accept_bool = <fun>;
     accept_float = <fun>; accept_int = <fun>; accept_int32 = <fun>;
     accept_int64 = <fun>; accept_nativeint = <fun>; accept_char = <fun>;
     accept_string = <fun>; accept_list = <fun>; accept_option = <fun>;
     accept_record = <fun>; accept_tuple = <fun>; accept_sum = <fun>}}

utop # let toml = Toml.Parser.(from_string "ints = [1, 2]\nstring = \"string value\"\n"
                               |> unsafe);;
val toml : Toml.Types.table = <abstr>

utop # Toml_cconv.decode_exn decode toml;;
- : t = {ints = [1; 2]; string = "string value"}

Limitations

  • Keys don't quite follow the TOML standard. Both section keys (eg, [key1.key2]) and ordinary keys (key=...) may not contain the following characters: space, \t, \n, \r, ., [, ], " and #.

Projects using toml

If you want to add your project, feel free to open a PR.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].