Function jsonb_array_element

Source
pub fn jsonb_array_element(v: JsonbRef<'_>, p: i32) -> Option<JsonbRef<'_>>
Expand description

Extracts n’th element of JSON array (array elements are indexed from zero, but negative integers count from the end).

jsonb -> integer → jsonb

§Examples

query T
select '[{"a":"foo"},{"b":"bar"},{"c":"baz"}]'::jsonb -> 2;
----
{"c": "baz"}

query T
select '[{"a":"foo"},{"b":"bar"},{"c":"baz"}]'::jsonb -> -3;
----
{"a": "foo"}