kw_get_int()
#
Retrieves an integer value from a JSON object by following a specified path. If the path does not exist, a default value is returned. Supports optional creation of the key if it does not exist.
Prototype
json_int_t kw_get_int(
hgobj gobj,
json_t *kw,
const char *path,
json_int_t default_value,
kw_flag_t flag
);
Parameters
Key |
Type |
Description |
---|---|---|
|
|
Pointer to the GObj context, used for logging errors. |
|
|
JSON object to search within. |
|
|
Path to the desired integer value within the JSON object. |
|
|
Default integer value to return if the path does not exist. |
|
|
Flags controlling behavior, such as |
Return Value
Returns the integer value found at the specified path, or the default_value
if the path does not exist or is not an integer.
Notes
If KW_CREATE
is set and the path does not exist, a new key is created with the default_value
. If KW_REQUIRED
is set and the path is missing, an error is logged.
Prototype
// Not applicable in JS
Prototype
# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples