kw_select()
#
kw_select()
returns a new JSON list containing duplicated objects from kw
that match the given jn_filter
. If match_fn
is NULL
, kw_match_simple()
is used as the default matching function.
Prototype
json_t *kw_select(
hgobj gobj,
json_t *kw, // NOT owned
json_t *jn_filter, // owned
BOOL (*match_fn) (
json_t *kw, // NOT owned
json_t *jn_filter // owned
)
);
Parameters
Key |
Type |
Description |
---|---|---|
|
|
A handle to the gobj (generic object) context. |
|
|
A JSON object or array to be filtered. It is not owned by the function. |
|
|
A JSON object containing the filter criteria. It is owned by the function. |
|
|
A function pointer used to match elements in |
Return Value
A new JSON array containing duplicated objects that match the filter criteria. The caller is responsible for freeing the returned JSON object.
Notes
If kw
is an array, each element is checked against jn_filter
, and matching elements are duplicated into the returned list.
If kw
is an object, it is checked against jn_filter
, and if it matches, it is duplicated into the returned list.
The returned JSON array contains duplicated objects, meaning they have new references and must be freed by the caller.
Prototype
// Not applicable in JS
Prototype
# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples