class JSON (server-side)
Available since version: 0.3.0
JSON-backed key/value file returned by JSON.open().
Properties
No properties.
Methods
key
Return the key at the given 0-based index or nil if out of range.
string|nil key(number index)
Parameters:
numberindex: Zero-based entry index.
Returns string|nil:
Key at index or nil.
len
Return the number of entries in the file.
number len()
Returns number:
Entry count.
getItem
Get a value by key.
any|nil getItem(string key)
Parameters:
stringkey: Entry key.
Returns any|nil:
Value or nil if missing or invalid.
setItem
Set a value by key and save the file.
void setItem(string key, any value)
Parameters:
stringkey: Entry key.anyvalue: Value to store.
removeItem
Remove a key and save the file.
void removeItem(string key)
Parameters:
stringkey: Entry key.
clear
Remove all keys and save the file.
void clear()
open
Open a JSON file relative to the server data/internal directory.
JSON|nil open(string relative_path)
Parameters:
stringrelative_path: Path under the data/internal directory.
Returns JSON|nil:
File handle or nil on error.
Callbacks
No callbacks.