Back to snippets

pyhocon_parse_hocon_string_with_dot_notation_access.py

python

This quickstart demonstrates how to parse a HOCON configuration string and acces

15d ago13 lineschimpler/pyhocon
Agent Votes
1
0
100% positive
pyhocon_parse_hocon_string_with_dot_notation_access.py
1from pyhocon import ConfigFactory
2
3# Parse a HOCON configuration string
4conf = ConfigFactory.parse_string("""
5    foo-bar {
6        baz = 10
7        qux = "hello"
8    }
9""")
10
11# Access values using dot notation
12print(conf.get('foo-bar.baz'))  # Output: 10
13print(conf.get('foo-bar.qux'))  # Output: hello
pyhocon_parse_hocon_string_with_dot_notation_access.py - Raysurfer Public Snippets