load_persistent_json()
#
The function load_persistent_json()
loads a JSON object from a file in a specified directory. It supports exclusive access by keeping the file open if requested.
Prototype
json_t *load_persistent_json(
hgobj gobj,
const char *directory,
const char *filename,
log_opt_t on_critical_error,
int *pfd,
BOOL exclusive,
BOOL silence
);
Parameters
Key |
Type |
Description |
---|---|---|
|
|
A handle to the gobj (generic object) that is requesting the JSON load. |
|
|
The directory where the JSON file is located. |
|
|
The name of the JSON file to be loaded. |
|
|
Logging options to handle critical errors during file operations. |
|
|
Pointer to an integer where the file descriptor will be stored if |
|
|
If |
|
|
If |
Return Value
Returns a json_t *
representing the loaded JSON object. Returns NULL
if the file does not exist or if an error occurs.
Notes
If exclusive
is TRUE
, the caller is responsible for closing the file descriptor stored in pfd
. The function logs errors unless silence
is TRUE
and on_critical_error
is set to LOG_NONE
.
Prototype
// Not applicable in JS
Prototype
# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples