Best way to create config files? / Does Julia support .toml natively?

#1

Hello,

I want to write a program that reads a config file with straight forward key-value information. The sort of thing that you could do with a TOML or YAML file. I’m wondering if there is a “standard” solution in Julia? I had assumed that TOML would be supported natively because it’s used by the Julia package manager. But that doesn’t seem to be the case. I’ve only found TOML.jl which doesn’t look quite like a polished product.

Anyway, I might just end up choosing between TOML.jl and YAML.jl. I just wanted to know if there was something obvious that I’ve missed.

Thanks for the help.

0 Likes

#2

Nope, I think you haven’t missed anything obvious. The Julia package manager actually uses its own updated version of TOML.jl which lives inside the Pkg repository: https://github.com/JuliaLang/Pkg.jl/tree/master/ext/TOML . You can access that internal TOML package via using Pkg; Pkg.TOML, but I wouldn’t necessarily recommend it for production code: I don’t think it’s guaranteed that Pkg.TOML will always be accessible or have a stable internal API in future versions of Pkg and Julia.

Fortunately, there is work underway right now to turn that internal TOML module into part of the Julia standard library: https://github.com/JuliaLang/Pkg.jl/issues/1011 Once that’s done, you’ll be able to do using TOML without having to install anything.

Until that time, you could use YAML.jl, or JSON.jl, or you could use Pkg.TOML (as long as you’re willing to change your code when it becomes a standard library in the future).

7 Likes

#3

Exactly what I needed to know. Thanks!

0 Likes

#4

The package ConfParser.jl seems quite convenient and well-maintained.

-erik

0 Likes

#5

It would be really nice if we can get TOML split off into a separate package so that it’s easier to use and maintain. I strongly prefer it to YAML, which is a bit of a mess in my opinion.

3 Likes

#6

It is WIP, see

I plan to contribute in the medium run.

1 Like