Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty strings in arrays are removed after parsing #232

Open
onilton opened this issue Jun 7, 2020 · 2 comments
Open

Empty strings in arrays are removed after parsing #232

onilton opened this issue Jun 7, 2020 · 2 comments

Comments

@onilton
Copy link

onilton commented Jun 7, 2020

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 onilton changed the title Empty strings in arrays are ignored Empty strings in arrays are removed after parsing Jun 7, 2020
@polopi
Copy link

polopi commented Oct 14, 2021

Same issue

@bpb
Copy link

bpb commented Sep 27, 2022

Same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants