UnQLite C/C++ API Reference - JSON Array/Object handling.
int (*xWalk)(unqlite_value *pKey,unqlite_value *pValue,void *pUserData),
Iterate over the elements of a given JSON array or object and invoke the supplied callback for each entry.
This routine iterate over the elements of a given array or object and invokes the supplied walker callback for each entry. The first argument (pArray) must be of type array or object obtained by a prior successful call to unqlite_vm_new_array(), unqlite_context_new_array() or passed as parameter to the foreign function. Otherwise, this routine return immediately and the walk process could not be done.
The most interesting parameter is the walker callback which is an user defined function that is invoked for each array or object entry. The callback must accept three arguments. The first argument is the entry key and the second argument is the entry value which could be any type even others JSON arrays and objects and the third and last argument is a copy of the third argument to this function which is forwarded verbatim by engine.
The callback must return UNQLITE_OK. Otherwise the walk process is aborted and this function return UNQLITE_ABORT.
The key and entry value could be extracted inside the callback using these interfaces:
Note: The key and its value are passed to the callback by copy. That is, any subsequent changes to their types or values is not reflected. If you want to modify the entry value use unqlite_array_fetch() instead.
Note2: This routine is not thread-safe.
unqlite_value to walk which must be of type array or object.
Arbitrary user pointer which is forwarded verbatim by the engine to the walker callback as its third argument.
UNQLITE_OK is returned on success. Any other return value indicates failure
Compile this C file for a smart introduction to the JSON array/object handling interfaces.