json_config()
#
The json_config()
function merges multiple JSON configurations into a single final configuration string, following a specific order of precedence. It also includes features like comment handling, variable substitution, and range-based expansion for flexibility and advanced use cases.
Source code in:
See Settings
Prototype
typedef enum {
PEF_CONTINUE = 0,
PEF_EXIT = -1,
PEF_ABORT = -2,
PEF_SYSLOG = -3,
} pe_flag_t;
PUBLIC char *json_config(
BOOL print_verbose_config, // Print intermediate configurations and exit(0) if TRUE.
BOOL print_final_config, // Print final configuration and exit(0) if TRUE.
const char *fixed_config, // Fixed JSON string (not writable).
const char *variable_config, // Writable JSON string.
const char *config_json_file, // Path to JSON file(s) for overwriting variable_config.
const char *parameter_config, // JSON string for parameterized overwrites.
pe_flag_t quit // Behavior flag on error (e.g., exit or continue).
);
Parameters
Parameter |
Type |
Description |
---|---|---|
|
|
If |
|
|
If |
|
|
A fixed JSON string that cannot be modified during merging. |
|
|
A writable JSON string that can be overwritten by subsequent inputs. |
|
|
Path(s) to JSON file(s) whose contents overwrite |
|
|
A JSON string for overwriting specific parameters in the final configuration. |
|
|
Controls program behavior on JSON parsing errors. For example, it can determine whether to exit the program or continue. |
Return Value
Return Value
Returns a dynamically allocated string containing the final merged JSON configuration.
Warning
Important: The returned string must be freed using jsonp_free()
to avoid memory leaks.
Prototype
// Not applicable in JS
Prototype
# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples