save_json_to_file()
#
The function save_json_to_file()
saves a JSON object to a file, creating the directory if necessary and applying the specified permissions.
Prototype
int save_json_to_file(
hgobj gobj,
const char *directory,
const char *filename,
int xpermission,
int rpermission,
log_opt_t on_critical_error,
BOOL create,
BOOL only_read,
json_t *jn_data
);
Parameters
Key |
Type |
Description |
---|---|---|
|
|
The GObj context, used for logging and error handling. |
|
|
The directory where the JSON file will be saved. |
|
|
The name of the JSON file to be created or overwritten. |
|
|
The permission mode for the directory (e.g., 02770). |
|
|
The permission mode for the file (e.g., 0660). |
|
|
Logging options for handling critical errors. |
|
|
If |
|
|
If |
|
|
The JSON object to be saved to the file. This parameter is owned by the function. |
Return Value
Returns 0
on success, or -1
if an error occurs.
Notes
The function ensures that the directory exists before saving the file. If only_read
is TRUE
, the file permissions are set to read-only after writing.
Prototype
// Not applicable in JS
Prototype
# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples