kw_find_json_in_list()

kw_find_json_in_list()#

Search for a JSON item in a JSON list and return its index. If the item is not found, return -1. The comparison is performed using json_is_identical().

Prototype

int kw_find_json_in_list(
    hgobj     gobj,
    json_t   *kw_list,  // not owned
    json_t   *item,     // not owned
    kw_flag_t flag
);

Parameters

Key

Type

Description

gobj

hgobj

Pointer to the gobj context.

kw_list

json_t *

JSON array to search within. Must not be NULL.

item

json_t *

JSON item to search for in kw_list. Must not be NULL.

flag

kw_flag_t

Flags to modify behavior. If KW_VERBOSE is set, errors will be logged.


Return Value

Returns the index of item in kw_list if found, otherwise returns -1.

Notes

If kw_list is not a JSON array or item is NULL, the function returns -1. If KW_VERBOSE is set in flag, an error message is logged when item is not found.

Prototype

// Not applicable in JS

Prototype

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