WTH are keys in yaml files (re-)sorted alphabetically by UI editors?

The process now converts YAML into JSON which strips away comments. When it converts back to YAML, it has no comments to write.

The suggestion is to convert from YAML to JSONC in order to preserve the comments. When it converts back, it has comments available to write.

Anyway, stopping it from sorting is already a big step in the right direction.


EDIT

Not seeing the comments displayed in the browser is an acceptable price for not having them silently deleted.

Where does it do that? I’ve been poking around the code, but I don’t see anywhere that it converts YAML to JSON. Is it in frontend?

Honestly, I haven’t looked at the code but I suspect it’s not even converting to JSON but directly into a python dict. So my request for supporting JSONC is probably misguided.

1 Like

It is not just not seeing them, we have to change the JSON in the editors, so the browser needs to parse it. JSON with comments can’t be parsed by a browser and edited.

1 Like

It is converted to JSON here: https://github.com/home-assistant/core/blob/181709f3d29842886a3c84c02d4e374b57432437/homeassistant/components/config/__init__.py#L120-L130

1 Like