pyhocon icon indicating copy to clipboard operation
pyhocon copied to clipboard

Empty strings in arrays are removed after parsing

Open onilton opened this issue 5 years ago • 5 comments

When adding a empty string "" in array, it is removed after parsing:

Small example

from pyhocon import ConfigFactory
from pyhocon import HOCONConverter

conf = ConfigFactory.parse_string('''
features: [
    less noisy / less pedantic syntax
    "hey"
    ""
    # ability to write comments
]

features2 = ["a", "b", "", "d"]
''')
print(conf.as_plain_ordered_dict())
print(HOCONConverter.to_json(conf))
print(conf)

Prints

OrderedDict([('features', ['less noisy / less pedantic syntax', 'hey']), ('features2', ['a', 'b', 'd'])])
{
  "features": [
    "less noisy / less pedantic syntax",
    "hey"
  ],
  "features2": [
    "a",
    "b",
    "d"
  ]
}
ConfigTree([('features', ['less noisy / less pedantic syntax', 'hey']), ('features2', ['a', 'b', 'd'])])

When using the regular (scala) HOCON: https://hocon-playground.herokuapp.com/

Output:

{
    "features" : [
        "less noisy / less pedantic syntax",
        "hey",
        ""
    ],
    "features2" : [
        "a",
        "b",
        "",
        "d"
    ]
}

onilton avatar Jun 07 '20 22:06 onilton

Same issue

polopi avatar Oct 14 '21 22:10 polopi

Same issue.

bpb avatar Sep 27 '22 18:09 bpb