API ReferenceJSON
Overview
Redis JSON operations allow you to store, retrieve, and manipulate JSON documents directly in Redix. This is perfect for complex nested data structures like character appearances, configurations, and dynamic game data. Requires Redis Stack.
Available Operations
Basic Operations
- JSONSet - Set a JSON document
- JSONGet - Get JSON data
- JSONGetMultiple - Get multiple paths
- JSONMGet - Get path from multiple documents
- JSONDel - Delete a path
- JSONType - Get type of value
Numeric Operations
- JSONNumIncrBy - Increment numeric value
- JSONNumMultBy - Multiply numeric value
Array Operations
- JSONArrAppend - Append to array
- JSONArrIndex - Find index of value
- JSONArrInsert - Insert into array
- JSONArrLen - Get array length
- JSONArrPop - Pop from array
- JSONArrTrim - Trim array
String Operations
- JSONStrAppend - Append to string
- JSONStrLen - Get string length
Object Operations
- JSONObjKeys - Get object keys
- JSONObjLen - Get number of keys
Utility
- JSONToggle - Toggle boolean
- JSONClear - Clear value
Use Cases
- Character appearance systems
- Dynamic configurations
- Inventory management
- Quest progress tracking
- Complex nested data
Quick Example
local Redix = exports.redix:GetInterface()
-- Save character appearance
Redix.JSONSet('character:123:appearance', '$', {
face = 1,
hair = 5,
tattoos = {{zone = 'head', id = 1}}
})
-- Update single field
Redix.JSONSet('character:123:appearance', '$.face', 3)
-- Add tattoo
Redix.JSONArrAppend('character:123:appearance', '$.tattoos', {
{zone = 'torso', id = 5}
})