Skip to content

JSONSource

A ConfigSource that loads values from a JSON file.

Parameters:

Name Type Description Default
path pathlib.Path

a pathlib.Path to a json file to load.

required
path_must_exist bool

if true, the constructor will raise a RuntimeError if the provided path doesn't exist.

required

_load_file(self, file) private

Loads and parses the json file

Source code in flex_config\file_sources\json_source.py
29
30
31
32
33
34
def _load_file(self, file: TextIO) -> Dict[str, Any]:
    """ Loads and parses the json file """
    import json

    config_dict = json.load(file)
    return config_dict