# \[ANN\] Configurations.jl - Options/Configurations made easy

**URL:** <https://discourse.julialang.org/t/ann-configurations-jl-options-configurations-made-easy/50669>\
**Category:** Package Announcements\
**Created:** [November 24, 2020, 5:12am UTC](https://discourse.julialang.org/t/ann-configurations-jl-options-configurations-made-easy/50669 "2020-11-24T05:12:20Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![JosephPollacco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josephpollacco/32/51404_2.png) [@JosephPollacco](https://discourse.julialang.org/u/JosephPollacco)\
**Post date:** [July 6, 2021, 8:33am UTC](https://discourse.julialang.org/t/ann-configurations-jl-options-configurations-made-easy/50669/23 "2021-07-06T08:33:52Z")

</div>

> [@Roger-luo](#):
>
> ```julia
> @option struct MyType
> "alpha"
> α::Int
> "omega"
> Ω::Float64 = 1.0
> end
> 
> ```

I am not sure if you really need it because in the toml file you can simply write:

```julia
[MyType]
    "α" = 1.0
    "Ω" = 1.0

```

---

<div class="post-metadata">

**Author:** ![Roger-luo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/roger-luo/32/3399_2.png) [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Post date:** [July 7, 2021, 2:00am UTC](https://discourse.julialang.org/t/ann-configurations-jl-options-configurations-made-easy/50669/24 "2021-07-07T02:00:56Z")

</div>

> [@JosephPollacco](#):
>
> Thanks, I am wandering if YAML format would be a better option as it seems to support symbols and Greek.

It’s up to you, but I don’t think the `Symbol` syntax is part of `YAML` standard specification I think it is a Julia specific thing in YAML.jl, thus you may have compatibility issues when you pass this to other people using other languages (e.g Python does not have the concept of `Symbol` or equivalent).

if you want to use TOML, you just need to overload `Configurations.convert_to_option`, it’s just one line, not sure why you don’t want to do it.

> [@JosephPollacco](#):
>
> It will be great if you can help to fix **from\_dict** which does not work.

You will need the dictionary to use `String` as your key, but YAML parser by default returns `Dict{Any, Any}`, I think the error message has explained what’s happening

````julia
ERROR: LoadError: MethodError: no method matching from_dict(::Type{OPTION}, ::Dict{Any, Any})
Closest candidates are:
  from_dict(::Type{T}, ::AbstractDict{String, V} where V; kw...) where T at C:\Users\pollaccoj\.julia\packages\Configurations\kq1sK\src\parse.jl:27```

````

so you want to write

```julia
YAML.load_file("test.yml"; dicttype=Dict{String, Any})

```

> [@JosephPollacco](#):
>
> I am not sure if you really need it because in the toml file you can simply write:

It’s needed when a REST API’s JSON schema is not defined by who writes the Julia struct, especially given that there are many other languages that do not support/encourage UTF8, but the Julia function we are going to call has UTF8 keywords which are quite common in Julia ecosystem.

I had a concrete use case when I wrap up JSON schema in IBM Quantum, but due to syntax conflict, this feature is removed since v0.12.0. The best way currently is to do the name convention manually.

**The latest version of this package is currently v0.16, so please always use the documentation as reference instead of this discourse announcement.**

---

<div class="post-metadata">

**Author:** ![Roger-luo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/roger-luo/32/3399_2.png) [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Post date:** [July 7, 2021, 2:06am UTC](https://discourse.julialang.org/t/ann-configurations-jl-options-configurations-made-easy/50669/25 "2021-07-07T02:06:03Z")

</div>

for the comment in your [other post](https://discourse.julialang.org/t/metaprogramming-with-structure-converting-dictionary-to-structure/63861/7)

> **My recommendation is that Configuration.jl should be part of the TOML package.**

no, it won’t be, this package is not specific to TOML, it supports TOML by default just because Julia has a TOML parser shipped with it.

---

<div class="post-metadata">

**Author:** ![Roger-luo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/roger-luo/32/3399_2.png) [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Post date:** [July 7, 2021, 2:55am UTC](https://discourse.julialang.org/t/ann-configurations-jl-options-configurations-made-easy/50669/26 "2021-07-07T02:55:31Z")

</div>

I realize the documentation was lack of examples of type conversions etc. so I just cut new patch release to update the documentations, this includes

- [Frequently Asked Questions](https://configurations.rogerluo.dev/stable/#Frequently-Asked-Questions)
- [Quick Start Guide](https://configurations.rogerluo.dev/stable/quick-start/)
- [Type Conversion](https://configurations.rogerluo.dev/stable/convert/)

Please remember to give a star if you find it’s helpful so that the future new releases will appear in your github feeding 😛

---

<div class="post-metadata">

**Author:** ![JosephPollacco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josephpollacco/32/51404_2.png) [@JosephPollacco](https://discourse.julialang.org/u/JosephPollacco)\
**Post date:** [July 11, 2021, 10:50pm UTC](https://discourse.julialang.org/t/ann-configurations-jl-options-configurations-made-easy/50669/27 "2021-07-11T22:50:06Z")

</div>

@Roger-luo I would like to give 10 ⭐ ⭐ ⭐ ⭐ ⭐ ⭐ ⭐ but can only give one

---

<div class="post-metadata">

**Author:** ![JosephPollacco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josephpollacco/32/51404_2.png) [@JosephPollacco](https://discourse.julialang.org/u/JosephPollacco)\
**Post date:** [July 11, 2021, 10:52pm UTC](https://discourse.julialang.org/t/ann-configurations-jl-options-configurations-made-easy/50669/28 "2021-07-11T22:52:01Z")

</div>

@Roger-luo I am wandering if we should not invent TOMLJ (TOML for JULIA). This is useful as a format to input parameters/options into JULIA specific models 😄

---

<div class="post-metadata">

**Author:** ![Roger-luo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/roger-luo/32/3399_2.png) [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Post date:** [July 11, 2021, 11:00pm UTC](https://discourse.julialang.org/t/ann-configurations-jl-options-configurations-made-easy/50669/29 "2021-07-11T23:00:12Z")

</div>

> [@JosephPollacco](#):
>
> I am wandering if we should not invent TOMLJ (TOML for JULIA). This is useful as a format to input parameters/options into JULIA specific models 😄

You mean “if we should invent TOMLJ”? I guess we can, as long as we make syntax highlights happy in the IDEs etc, and as long as you implement a set of default string syntax for Julia types, I think you can just get it out of the box, but if you are fine with Julia specific things, you can also just use YAML which supports more syntax by its standard.

The only thing to be careful of is when you want other language users to be able to use your config file, be careful with the Julia-specific parts, since things like `:symbol` might be valid syntax in other languages or it could mean different things in another programming language.

I didn’t support this type of thing in the default conversion rules because the string syntax has some ambiguity based on context, e.g one my want `":symbol"` to be converted to a `Symbol` when the type is `Union{Symbol, String}`, or sometimes one just want the string to be converted to a `Symbol` when the type is just `Symbol`.

So doing Julia-specific things is definitely possible and simple to do with Configurations by adding some extra type conversion rules from `String`, but we will need a separate package for that to enforce Julia specific things.

[Previous page](https://discourse.julialang.org/t/ann-configurations-jl-options-configurations-made-easy/50669.md?page=1)
