vstakhov / libucl

Universal configuration library parser
BSD 2-Clause "Simplified" License
1.62k stars 138 forks source link

README doesn't match actual behaviour #284

Open vthriller opened 6 months ago

vthriller commented 6 months ago

From README.md:

UCL accepts named keys and organize them into objects hierarchy internally. Here is an example of this process:

section "blah" {
  key = value;
}
section foo {
  key = value;
}

is converted to the following object:

section {
  blah {
      key = value;
  }
  foo {
      key = value;
  }
}

Yet section is currently parsed as a list of multiple dicts instead of a unified dict:

In [1]: import ucl

In [2]: ucl.load('''
   ...: section "blah" {
   ...:     key = value;
   ...: }
   ...: section foo {
   ...:     key = value;
   ...: }
   ...: ''')
Out[2]: {'section': [{'blah': {'key': 'value'}}, {'foo': {'key': 'value'}}]}

No idea whether this is actual regression or just docs being outdated, hence this issue.

Tested with:

libucl $ git show
commit edf094c0d2150e1494a877cbe06b651a306a0589 (HEAD, tag: 0.9.0)
Crest commented 5 months ago

I can confirm that the resulting UCL parser root object contains a multi-valued "section" which presents to most ways to iterate/emit the object as an (implicit) array of multiple sub-objects instead of a single merged sub-object.