开发者

Config file format

does anyone knows a file format for configuration files easy 开发者_如何学编程to read by humans? I want to have something like tag = value where value may be:

  • String
  • Number(int or float)
  • Boolean(true/false)
  • Array(of String values, Number values, Boolean values)
  • Another structure(it will be more clear what I mean in the fallowing example)

Now I use something like this:

  • IntTag=1
  • FloatTag=1.1
  • StringTag="a string"
  • BoolTag=true
  • ArrayTag1=[1 2 3]
  • ArrayTag2=[1.1 2.1 3.1]
  • ArrayTag3=["str1" "str2" "str3"]
  • StructTag=
  • {
  • NestedTag1=1
  • NestedTag2="str1"
  • }

and so on.

Parsing is easy but for large files I find it hard to read/edit in text editors. I don't like xml for the same reason, it's hard to read. INI does not support nesting and I want to be able to nest tags. I also don't want a complicated format because I will use limited kind of values as I mentioned above.

Thanks for any help.


What about YAML ? It's easy to parse, nicely structured has wide programming language support. If you don't need the full feature set, you could also use JSON.


Try YAML - is (subjectively) easy to read, allows nesting, and is relatively simple to parse.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜