Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 734
Mircea Ispas Avatar asked May 28 '10 08:05

Mircea Ispas


2 Answers

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.

like image 96
chiborg Avatar answered Sep 20 '22 18:09

chiborg


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

like image 39
Piskvor left the building Avatar answered Sep 20 '22 18:09

Piskvor left the building