Repository navigation
MySQL_GetJSONInt
imshooter edited this page Oct 24, 2026
·
1 revision
A value of a JSON cell as an integer.
native MySQL_GetJSONInt(row, const field[], const key[], fallback = 0);| Parameter | Description | Default |
|---|---|---|
row |
The row, from 0. |
|
const field[] |
Name of the field. | |
const key[] |
Member of the top object or a JSON Pointer. | |
fallback |
What it gives when the value does not exist, is null, or is an object or an array. | 0 |
A float is cut to a whole number, a boolean reads as 0 or 1 and a string holding a number is read as that number. A key the cell lacks gives fallback, so a value added in a later version of a script has a default for the rows saved before.
forward OnItemRead(itemid);
public OnItemRead(itemid) {
new const
amount = MySQL_GetJSONInt(0, "attributes", "amount", 1),
Float:condition = MySQL_GetJSONFloat(0, "attributes", "condition", 100.0),
bool:locked = MySQL_GetJSONBool(0, "attributes", "locked")
;
printf("item %i: %i, %.1f%%, %s", itemid, amount, condition, locked ? ("locked") : ("open"));
return 1;
}- MySQL_GetJSONFloat: A value of a JSON cell as a float.
- MySQL_GetJSONBool: A value of a JSON cell as a bool.
- MySQL_GetJSONType: The type of a value of a JSON cell.
MySQL 0.2.0 · Repository · Releases · MIT License
Guides
- Installation
- Configuration
- Queries
- Results
- JSON cells
- Prepared statements
- Passwords
- Errors
- TLS
- Coming from R41
- Performance
Reference
Functions