You are viewing a single thread.
View all comments View context
19 points

TOML is mainly for humans to write, certainly not a good choice if you’re programmatically writing files - comments and formatting would be lost.

permalink
report
parent
reply
6 points

It all depends on the library you use. Rust has you covered with toml_edit. It is what is used for all the cargo commands editing the Cargo.toml file.

permalink
report
parent
reply
2 points
*

Agreed. Except that it’s not easier to write imo

permalink
report
parent
reply
9 points

Where do you put your comments in JSON files?

permalink
report
parent
reply
4 points
*

I’ve seen them included as part of the data.

"//": "Comment goes here",

Example here.

permalink
report
parent
reply
1 point

For settings files I always have an example file with sensible values filled in and along with descriptive keys that serves as reasonable documentation. If something is truly unknowable, I’ve probably done something wrong.

permalink
report
parent
reply
6 points

The very first moment that I had to use JSON as a configuration format, and I was desperate to find a way to make a long string into a JSON field. JSON is great for many things, but it’s not good at all for a configuration format where you need users to make it pretty, and need features like comments or multi-line strings (because you don’t want to fix a merge conflict in a 400 character-wide line).

permalink
report
parent
reply

Programming

!programming@programming.dev

Create post

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you’re posting long videos try to add in some form of tldr for those who don’t want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



Community stats

  • 3.7K

    Monthly active users

  • 1.8K

    Posts

  • 29K

    Comments