Our great sponsors
- InfluxDB - Collect and Analyze Billions of Data Points in Real Time
- Sonar - Write Clean Python Code. Always.
- Revelo Payroll - Free Global Payroll designed for tech teams
- Onboard AI - Learn any GitHub repo in 59 seconds
-
JSON is basically perfect if it allowed trailing commas and comments. TOML is not a replacement for JSON because of how badly it chokes on nested lists of objects (both hard to read and hard to write), due to a misguided attempt to avoid becoming JSON-like[1].
-
> JSON is basically perfect if it allowed trailing commas and comments.
I agree, especially in regards to the comments, because sometimes the data itself isn't enough and additional human-readable context can be really useful!
In that regard, JSON5 is a wonderful idea, even if sadly it isn't widespread: https://json5.org/
It also supports the trailing commas and overall just feels like what JSON should be, to make it better without overcomplicating it.
-
InfluxDB
Collect and Analyze Billions of Data Points in Real Time. Manage all types of time series data in a single, purpose-built database. Run at any scale in any environment in the cloud, on-premises, or at the edge.
-
Funny thing: TOML author/inventor calls it a mistake:
> TOML is a bad file format. It looks good at first glance, and for really really trivial things it is probably good. But once I started using it and the configuration schema became more complex, I found the syntax ugly and hard to read.
> I personally abandoned TOML and as such, I'm not planning on adding any new features
https://github.com/avakar/pytoml/issues/15#issuecomment-2177...
-
I pretty like the idea of a superset of JSON taht supports (1) comments, (2) trailing commas, (3) unquoted properties, (4) optional {} for the root object, (5) multi-line strings, (6) number separator.
JSON6 proposal [1] supports all of this, except (4). Unfortunately it also supports more and make the spec a bit too complex for my taste (JSON has a compact spec; any extension should honor this). Same issue with JSON5 proposal [2].
EKON [3] is certainly the best candidate. However, it doesn't get any traction.
-
-
Among types and other useful properties, CUE supports everything you asked for.
-
If one is looking for an alternative config format, the best designed I've seen is https://github.com/gura-conf/gura
-
Sonar
Write Clean Python Code. Always.. Sonar helps you commit clean code every time. With over 225 unique rules to find Python bugs, code smells & vulnerabilities, Sonar finds the issues while you focus on the work.
-
-
I played around with "format preserving" edits of a few text formats, including nested formats (a JSON inside a TOML inside a YAML etc)
-
I like Google's Jsonnet [1], which has all of this except for 4.
Jsonnet is quite mature, with fairly wide language adoption, and has the benefit of supporting expressions, including conditionals, arithmetic, as well as being able to define reusable blocks inside function definitions or external files.
It's not suitable as a serialization format, but great for config. It's popular in some circles, but I'm sad that it has not reached wider adoption.
-
> In my experience (Python and Rust) missing keys are errors, not silently converted to None:
In Rust it's possible to deserialize to an Option.
https://play.rust-lang.org/?version=stable&mode=debug&editio...
-
Can you share an actual example where you need to specify requirements twice. With pyproject.toml I know of 3 ways requirements are specified and they are all used by different things:
1. Build requirements - requirements needed to build your package from an sdist
2. Runtime requirements - requirements your library needs at runtime
3. Extra requirements - optional runtime requirements
For example my library pyspnego https://github.com/jborean93/pyspnego/blob/main/pyproject.to... has all 3:
1. Cython for Win32 needed to build the sdist and setuptools as the general build system - https://github.com/jborean93/pyspnego/blob/c3db058b636fc102f...
2. cryptography as a runtime dependency - https://github.com/jborean93/pyspnego/blob/c3db058b636fc102f...
3. optional extras kerberos and yaml - https://github.com/jborean93/pyspnego/blob/c3db058b636fc102f...
Granted the toml format and what is used in pyproject.toml has it's warts but I'm curious what your joke and clown_fiesta examples are actually from as from where I am standing each section currently serve different purposes.