views:

40

answers:

2
+6  Q: 

Config file format

Hello, 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.

+2  A: 

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

Piskvor
+2  A: 

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.

chiborg
The format i currently use is very similar with JSON( I didn't know about JSON until now:P), but is hard to read for files with 300-400 lines or more.
Felics
Have a look at this question: http://stackoverflow.com/questions/357521/is-there-a-decent-json-editor-around
chiborg