Function jsonb_extract_path_text

Source
pub fn jsonb_extract_path_text(
    v: JsonbRef<'_>,
    path: impl Row,
    writer: &mut impl Write,
) -> Option<()>
Expand description

Extracts JSON sub-object at the specified path as text.

  • jsonb #>> text[] → text
  • jsonb_extract_path_text ( from_json jsonb, VARIADIC path_elems text[] ) → text

§Examples

query T
select '{"a": {"b": ["foo","bar"]}}'::jsonb #>> '{a,b,1}'::text[];
----
bar

query T
select '{"a": {"b": ["foo",null]}}'::jsonb #>> '{a,b,1}'::text[];
----
NULL

query T
select '{"a": {"b": ["foo","bar"]}}'::jsonb #>> '{a,b,null}'::text[];
----
NULL

query T
select jsonb_extract_path_text('{"a": {"b": ["foo","bar"]}}', 'a', 'b', '1');
----
bar

query T
select jsonb_extract_path_text('{"a": {"b": ["foo","bar"]}}', variadic array['a', 'b', '1']);
----
bar