kw_get_dict()

kw_get_dict()#

Retrieves the dictionary value from the kw JSON object at the specified path. If the key does not exist, it returns default_value or creates a new entry if KW_CREATE is set.

Prototype

json_t *kw_get_dict(
    hgobj      gobj,
    json_t     *kw,
    const char *path,
    json_t     *default_value,
    kw_flag_t  flag
);

Parameters

Key

Type

Description

gobj

hgobj

Handle to the calling object, used for logging errors.

kw

json_t *

JSON object to search within.

path

const char *

Path to the dictionary key, using the configured delimiter.

default_value

json_t *

Default value to return if the key is not found.

flag

kw_flag_t

Flags controlling behavior, such as KW_CREATE to create the key if missing.


Return Value

Returns the dictionary value at path if found. If KW_CREATE is set, it creates and returns a new dictionary. If the key is missing and KW_REQUIRED is set, an error is logged and default_value is returned.

Notes

If KW_EXTRACT is set, the retrieved value is removed from kw. The function logs an error if path does not exist and KW_REQUIRED is set.

Prototype

// Not applicable in JS

Prototype

# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples