kw_set_subdict_value()
#
The function kw_set_subdict_value()
sets a key-value pair inside a subdictionary located at the specified path within a JSON object. If the subdictionary does not exist, it is created.
Prototype
int kw_set_subdict_value(
hgobj gobj,
json_t *kw,
const char *path,
const char *key,
json_t *value // owned
);
Parameters
Key |
Type |
Description |
---|---|---|
|
|
A handle to the gobj (generic object) that may be used for logging or context. |
|
|
A JSON object where the subdictionary is located. |
|
|
The path to the subdictionary within |
|
|
The key to be set inside the subdictionary. |
|
|
The JSON value to be assigned to |
Return Value
Returns 0
on success, or -1
if an error occurs (e.g., if kw
is not a valid JSON object).
Notes
If the subdictionary at path
does not exist, it is created as a new JSON object. The function uses kw_get_dict()
to retrieve or create the subdictionary.
Prototype
// Not applicable in JS
Prototype
# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples