API ReferenceJSON
JSONArrIndex
Find the index of a value in a JSON array
Syntax
Redix.JSONArrIndex(key, path, value, start, stop, callback)Parameters
- key
string: The key for the JSON document - path
string: JSONPath to the array - value
any: Value to search for - start
numberoptional: Starting index (default 0) - stop
numberoptional: Stopping index (default 0 = end) - callback
functionoptional: Callback function
Returns
number: Index of the value, or -1 if not found
Example
Redix.JSONArrIndex('character:123', '$.inventory', {item = 'sword'},
function(err, index)
if index ~= -1 then
print('Sword found at index:', index)
end
end
)