Repository navigation
MySQL_GetJSONValueInt
imshooter edited this page Nov 3, 2026
·
1 revision
A value of a JSON cell as an integer.
A value that does not exist, is null, or is an object or an array leaves value as it was.
native bool:MySQL_GetJSONValueInt(row, const field[], const key[], &value);| Parameter | Description |
|---|---|
row |
The row, from 0. |
const field[] |
Name of the field. |
const key[] |
Member of the top object or a JSON Pointer. |
&value |
Variable for the integer. |
-
truewhen the integer was written. -
falsewhen the value does not exist or is not a number, a bool or a string.
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 leaves the variable as it was, so a value added in a later version of a script keeps its default for the rows saved before.
forward OnItemRead(itemid);
public OnItemRead(itemid) {
new
amount = 1,
Float:condition = 100.0,
bool:locked
;
MySQL_GetJSONValueInt(0, "attributes", "amount", amount);
MySQL_GetJSONValueFloat(0, "attributes", "condition", condition);
MySQL_GetJSONValueBool(0, "attributes", "locked", locked);
printf("item %i: %i, %.1f%%, %s", itemid, amount, condition, locked ? ("locked") : ("open"));
return 1;
}- MySQL_GetJSONValueFloat: A value of a JSON cell as a float.
- MySQL_GetJSONValueBool: A value of a JSON cell as a bool.
- MySQL_GetJSONType: The type of a value of a JSON cell.
MySQL 0.3.0 · Repository · Releases · MIT License
Guides
- Installation
- Configuration
- Queries
- Results
- JSON cells
- Prepared statements
- Passwords
- Errors
- TLS
- Coming from R41
- Performance
Reference
Functions