JSON_ARRAY_GET

Overview

Returns the element at the specified index from a JSON array as a STRING (including JSON quotes). Returns NULL if the index is out of bounds.

Syntax

JSON_ARRAY_GET(<json_array>, <index>)

Parameters

  • <json_array>: JSON type, must be a JSON array. Strings must first be converted using PARSE_JSON.
  • <index>: BIGINT type, a non-negative integer index starting from 0.

Examples

SELECT json_array_get(PARSE_JSON('["a","b","c"]'), 0); -- "a" SELECT json_array_get(PARSE_JSON('["a","b","c"]'), 2); -- "c" -- Index out of bounds returns NULL SELECT json_array_get(PARSE_JSON('["a","b","c"]'), 5); -- NULL