I have a settings.json file full with useful comments (sometimes C-style and sometimes Python), and I'm programmatically modifying them with e.g. json library, but when I save the modified one I lose all the comments explaining the fields. Another inconvenience is losing the indentations and spacing therein.
Is there a 'neat' way of modifying the file programmatically?
jsonmodule, it (like JSON itself) doesn't support comments. It can pretty-print to the file though, so it's unclear what problem you've had there.