Skip to content

JSON Cells

imshooter edited this page Nov 29, 2026 · 1 revision

A JSON cell is parsed the first time a cache_get_json native reads it. A key is a member of the top object, or a JSON Pointer when it starts with a slash, as /position/0. With the latin1 character set, keys and strings are in the code page of the game, escaped ones such as ç included.

forward OnBagRead();

public OnBagRead() {
    new
        name[32],
        amount,
        Float:x
    ;

    cache_get_json_value(0, "data", "name", name);
    cache_get_json_int(0, "data", "amount", amount);
    cache_get_json_float(0, "data", "/position/0", x);

    return 1;
}
Native Reads
cache_get_json_type the type of a value, as MYSQL_JSON_OBJECT
cache_get_json_count the members of an object or the items of an array
cache_get_json_key the name of a member by its position
cache_get_json_value a value as text, objects and arrays as their JSON
cache_get_json_int, cache_get_json_float, cache_get_json_bool a value into a variable

The types are MYSQL_JSON_NONE for a missing value, MYSQL_JSON_NULL, MYSQL_JSON_BOOL, MYSQL_JSON_INT, MYSQL_JSON_FLOAT, MYSQL_JSON_STRING, MYSQL_JSON_ARRAY and MYSQL_JSON_OBJECT. %j writes a string as a JSON string inside a query.

Home

Guides

Reference

Functions

Connections
Queries
Cache
JSON cells
ORM
Queries built in pieces
Prepared statements
Batches
Transactions
Passwords
Callbacks

Clone this wiki locally