chimpler / pyhocon

HOCON parser for Python
Apache License 2.0
502 stars 118 forks source link

Incorrect parsing of quoted keys #311

Open mgrandi opened 1 year ago

mgrandi commented 1 year ago

pyhocon version 0.3.60

given the config:

group_key {

    key_one = "one"

    "key.two" = "two"
}

when you parse it with lightbend config:

        // -Dconfig.file=C:/Users/auror/Temp/csgo_workshop_download_temp/test_hocon.conf
        Config conf = ConfigFactory.load();
        Config c2 = conf.getConfig("group_key");

        System.out.println("c2: " + c2.toString());

you get:

c2: Config(SimpleConfigObject({"key.two":"two","key_one":"one"}))

but with pyhocon:


> python
Python 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyhocon
>>> config = pyhocon.ConfigFactory.parse_file("C:/Users/auror/Temp/csgo_workshop_download_temp/test_hocon.conf")
>>> print(config)
ConfigTree([('group_key', ConfigTree([('key_one', 'one'), ('"key.two"', 'two')]))])
>>>

note how the quoted key is double wraped in quotes, it should be key.two rather than "key.two"