OHocon is a port of lightbend's config library.
First, you must create a TypeSafeConfig
object by parsing an external resource(e.g. a file).
open OHocon
(* load from a string *)
let config = TypeSafeConfigFactory.parse_string "{name:\"john\"}"
(* load from a file *)
let config = TypeSafeConfigFactory.parse_file "/tmp/application.conf"
open OHocon
let config = TypeSafeConfigFactory.parse_string "{name:\"john\",countries:[\"jp\", \"us\"]}"
(* get string. Throw an exception if none. *)
let _ = TypeSafeConfig.get_string "name"
(* get string as string option. *)
let _ = TypeSafeConfig.get_string_opt "name"
(* get a list of string. *)
let _ = TypeSafeConfig.get_string_list "countries"
open OHocon
let config = TypeSafeConfigFactory.parse_string "{ id: 1, follower_ids: [2,3,4] }"
(* get int. Throw an exception if none. *)
let _ = TypeSafeConfig.get_int "id"
(* get int as int option. *)
let _ = TypeSafeConfig.get_int_opt "id"
(* get a list of int. *)
let _ = TypeSafeConfig.get_int_list "follower_ids"
Items | Status |
---|---|
Comments | ❌ |
Omit root braces | ❌ |
Key-value separator | ❌ |
Commas | ❌ |
Whitespace | ❌ |
Duplicate keys and object merging | ❌ |
Unquoted strings | ❌ |
Multi-line strings | ❌ |
String value concatenation | ❌ |
Array concatenation | ❌ |
Object concatenation | ❌ |
Arrays without commas | ❌ |
Path expressions | ❌ |
Paths as keys | ❌ |
Substitutions | ❌ |
Self-referential substitutions | ❌ |
The += separator |
❌ |
Includes | ❌ |
Include semantics: merging | ❌ |
Include semantics: substitution | ❌ |
Include semantics: missing files | ❌ |
Include semantics: file formats and extensions | ❌ |
Include semantics: locating resources | ❌ |
Include semantics: preventing cycles | ❌ |
Conversion of numerically-index objects to arrays | ❌ |