libucl icon indicating copy to clipboard operation
libucl copied to clipboard

README doesn't match actual behaviour

Open vthriller opened this issue 1 year ago • 1 comments

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)

vthriller avatar Mar 06 '24 06:03 vthriller

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.

Crest avatar Apr 02 '24 15:04 Crest