pyhocon icon indicating copy to clipboard operation
pyhocon copied to clipboard

dict key string portions are dropped, or extra quotes added

Open nmz787-intel opened this issue 9 months ago • 2 comments

pyhocon version 0.3.60

example code trying to load a dict:

from pyhocon import ConfigFactory

my_dict = {
    "myStuff": {
        "myThing_r0.1": ["someVal"],
    }
}

cfg = ConfigFactory.from_dict(my_dict)

print(f"expectation:\n{my_dict['myStuff'].keys()}")
print(f"actual:\n{cfg['myStuff'].keys()}")

output:

expectation:
dict_keys(['myThing_r0.1'])
actual:
odict_keys(['myThing_r0'])

you can see the .1 got dropped from the key.




In another attempt, to replicate loading a settings file:

from pyhocon import ConfigFactory

my_dict_str = """{
    "myStuff": {
        "myThing_r0.1": ["someVal"],
    }
}
"""

cfg = ConfigFactory.parse_string(my_dict_str)

print(f"actual:\n{cfg['myStuff'].keys()}")

the output is:

actual:
odict_keys(['"myThing_r0.1"'])

and you can see extra quotes getting added

nmz787-intel avatar Mar 04 '25 20:03 nmz787-intel

I think you might need to add another set of quotes..

abc.1 should turn into config[abc][1] vs ‘abc.1’ to config[abc.1]

davlee1972 avatar Apr 14 '25 14:04 davlee1972

I think you might need to add another set of quotes..

abc.1 should turn into config[abc][1] vs ‘abc.1’ to config[abc.1]

I have same issue, when parse string with quoted key, like { "myThing_r0.1": ["someVal"], } the parsed key have additional double quote, '"myThing_r0.1"'. What do you mean "another set of quotes"?

Thanks

yuntaoL avatar Nov 01 '25 07:11 yuntaoL