fn jsonb_exists(left: JsonbRef<'_>, key: &str) -> bool
Expand description
Does the text string exist as a top-level key or array element within the JSON value?
Examples:
# String exists as array element:
query B
SELECT '["foo", "bar", "baz"]'::jsonb ? 'bar';
----
t
# String exists as object key:
query B
SELECT '{"foo": "bar"}'::jsonb ? 'foo';
----
t
# Object values are not considered:
query B
SELECT '{"foo": "bar"}'::jsonb ? 'bar';
----
f
# As with containment, existence must match at the top level:
query B
SELECT '{"foo": {"bar": "baz"}}'::jsonb ? 'bar';
----
f
# A string is considered to exist if it matches a primitive JSON string:
query B
SELECT '"foo"'::jsonb ? 'foo';
----
t