Redix LogoDocumentation
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 number optional: Starting index (default 0)
  • stop number optional: Stopping index (default 0 = end)
  • callback function optional: 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
)