配置文件语法
我正在开发将利用配置文件的软件。我不知道配置文件的很多语法或格式。以下是我所知道的两个:(
与 .conf 文件常见)
[section]
key=value
#comment
或(与 .ini 常见)
key value
; comment
我的兴趣是几乎是一种语言的多功能事物。假设
[Default]
Start = 0
End = 10
Speed = 1
[Section 3-6]
Speed = 2
这将充当覆盖。然而,据我所知,这不是任何约定。是否有允许这样做的通用语法?
I'm developing software that will utilize a config file. I don't know many syntaxes or formats of config files. Here are the two I know:
(common with .conf files)
[section]
key=value
#comment
or (common with .ini)
key value
; comment
My interest is something versatile that's almost a language. Let's say
[Default]
Start = 0
End = 10
Speed = 1
[Section 3-6]
Speed = 2
This would act as an override. However this isn't any convention that I know of. Is there a common syntax that allows for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
截至 2015 年,xml 不再是事实上的标准。以下是选项。
TOML
YAML
CSON
JSON5 和 Human JSON - 灵活的 json 超集
属性文件 - 由 java 程序使用
As of 2015, xml is no longer the de facto standard. Here are options.
TOML
YAML
CSON
JSON5 and Human JSON - flexible json supersets
Properties File - used by java programs
这个曾经有效的答案将在 2020 年被否决,所以我对其进行了编辑。
2011年,我建议你使用xml格式。这是当时事实上的标准。
配置文档可能如下所示:
有许多库可以解析此类文件。
This once-valid answer is being voted down in 2020, so I edited it.
In 2011, I suggested you use an xml format. This was the de-facto standard then.
The configuration document could have looked like this:
There are many libraries to parse such files.