Skip to content

Empty strings in arrays are removed after parsing #232

@onilton

Description

@onilton

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"
    ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions