Skip to content

MySQL_GetJSONKey

imshooter edited this page Oct 24, 2026 · 1 revision

The name of a member of an object of a JSON cell, by its position.

native bool:MySQL_GetJSONKey(
    row,
    const field[],
    index,
    key[],
    size = sizeof (key),
    const path[] = ""
);

Parameters

Parameter Description Default
row The row, from 0.
const field[] Name of the field.
index The member, from 0.
key[] Array for the name.
size Size of the array. sizeof (key)
const path[] JSON Pointer of the object, or empty for the top one. ""

Returns

  • true when the name was written.
  • false when the object has no such member.

Remarks

The keys come in the order the cell holds them. With path, it reads the keys of an object inside the cell.

Example

Prints every member of a JSON cell.

stock PrintSettings(row) {
    new
        key[32],
        value[64]
    ;

    for (new i, count = MySQL_GetJSONCount(row, "settings"); i != count; ++i) {
        MySQL_GetJSONKey(row, "settings", i, key);
        MySQL_GetJSONString(row, "settings", key, value);
        printf("%s = %s", key, value);
    }
}

Related

  • MySQL_GetJSONCount: How many members an object of a JSON cell has, or how many elements an array has.
  • MySQL_GetJSONString: A value of a JSON cell as a string. An object or an array is written as JSON.

Clone this wiki locally