dump a python dict to a hocon file
I see there is option for dumping json, yaml and properties format, but is there a way to dump to hocon itself?
import pyhocon
config = pyhocon.ConfigTree()
d = {'foo':1, 'bar':2, 'baz':3}
config['example'] = d
with open("example.conf","w") as outfile:
outfile.write(pyhocon.HOCONConverter.to_hocon(config))
@dsynkov , In your example the result is: example {'foo': 1, 'bar': 2, 'baz': 3} But isn't this output is invalid because hocon is based off json. The ouput should have have single quotes wrapped around keys.
@liamz39 , I was looking for a simple library to write the conf files.
https://stackoverflow.com/questions/59417529/how-can-i-generate-hocon-conf-file-dynamically-using-pyhocon-in-python-3/59430263#59430263
From what I have read, it seems like pyhocon only has two ways to write hocon conf files. One is JSON and the other is an off looking style using that HOCONConverter.to_hocon method. I say off because when it writes, it looks different than any of the styles documented by lightbend. I guess I will stick to the json. If you have figured out more, please respond.