kw_get_subdict_value()
#
Retrieve a value from a subdictionary within a JSON object. If the subdictionary does not exist, it can be created based on the provided flags. The function searches for the key within the subdictionary and returns the corresponding value.
Prototype
json_t *kw_get_subdict_value(
hgobj gobj,
json_t *kw,
const char *path,
const char *key,
json_t *jn_default_value, // owned
kw_flag_t flag
);
Parameters
Key |
Type |
Description |
---|---|---|
|
|
Pointer to the GObj (generic object) context. |
|
|
JSON object containing the dictionary to search within. |
|
|
Path to the subdictionary within the JSON object. |
|
|
Key to retrieve from the subdictionary. |
|
|
Default value to return if the key is not found. This value is owned by the caller. |
|
|
Flags controlling behavior, such as whether to create the subdictionary if it does not exist. |
Return Value
Returns the JSON value associated with the specified key in the subdictionary. If the key is not found, the default value is returned. If KW_CREATE
is set, the subdictionary is created if it does not exist.
Notes
If KW_REQUIRED
is set and the key is not found, an error is logged. If KW_EXTRACT
is set, the value is removed from the dictionary before returning.
Prototype
// Not applicable in JS
Prototype
# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples