Pros and cons for different configuration formats?

后端 未结 4 1697
梦如初夏
梦如初夏 2021-02-02 06:37

I\'ve seen people using *.cfg (Python Buildout), *.xml (Gnome), *.json (Chrome extension), *.yaml (Google App Engine), *.ini and even *.py for app configuration files (like Djan

4条回答
  •  南笙
    南笙 (楼主)
    2021-02-02 06:59

    It really depends on whether the reader/writer of the configuration file is, or can be, a non-programmer human or if it has strictly programmatic access.

    XML, JSON, etc., are totally unsuitable for human consumption, while the INI format is half-way reasonable for humans.

    If the configuration file has only programmatic access (with occasional editing by a programmer), then any of the supported formats (XML, JSON, or INI) are suitable. The INI file is not suitable for structured parameters, where XML and JSON can support arrays, structs/objects, etc.

提交回复
热议问题