hocon v0.1.2 Hocon View Source
This module paresed and decodes a hocon configuration string.
specification coverages:
- [ ] parsing JSON
- [x] comments
- [x] omit root braces
- [x] key-value separator
- [x] commas are optional if newline is present
- [x] whitespace
- [x] duplicate keys and object merging
- [x] unquoted strings
- [x] multi-line strings
- [x] value concatenation
- [x] object concatenation
- [x] array concatenation
- [x] path expressions
- [x] path as keys
- [ ] substitutions
- [ ] includes
- [x] conversion of numerically-indexed objects to arrays
- [ ] allow URL for included files
- [ ] duration unit format
- [ ] period unit format
- [ ] size unit format
Example
iex(1)> conf = ~s(animal { favorite : "dog" }, key : """${animal.favorite} is my favorite animal""")
"animal { favorite : \"dog\" }, key : \"\"\"${animal.favorite} is my favorite animal\"\"\""
iex(2)> Hocon.decode(conf)
{:ok,
%{"animal" => %{"favorite" => "dog"}, "key" => "dog is my favorite animal"}}
Link to this section Summary
Functions
Parses and decodes a hocon string and returns a map
Link to this section Functions
Parses and decodes a hocon string and returns a map
options
:convert_numerically_indexed
- if set to true then numerically-indexed objects are converted to arrays:strict_conversion
- if set totrue
then numerically-indexed objects are only converted to arrays if all keys are numbers
Example
iex(1)> conf = ~s(animal { favorite : "dog" }, key : """${animal.favorite} is my favorite animal""")
"animal { favorite : \"dog\" }, key : \"\"\"${animal.favorite} is my favorite animal\"\"\""
iex(2)> Hocon.decode(conf)
{:ok,
%{"animal" => %{"favorite" => "dog"}, "key" => "dog is my favorite animal"}}