Reputation: 127
I want to use function "jsonb_extract_path_text", but it gives no result. I started with Hibernate and CriteriaBuilder, but eventually I simplified my situation.
Now I have several lines in pgAdmin Query Tool (also tested in psql console) and examples from the PostgreSQL Documentation.
First statement with the operator works fine:
SELECT '{"a": {"b":{"c": "foo"}}}'::jsonb#>>'{a,b}';
and it gives me
{"c": "foo"}
When I try to use the appropriate function and pass both operands as an arguments:
SELECT jsonb_extract_path_text('{"a": {"b":{"c": "foo"}}}'::jsonb , '{a,b}');
it gives me NULL.
I also tried to define path using the array constructor:
SELECT jsonb_extract_path_text('{"a": {"b":{"c": "foo"}}}'::jsonb , ARRAY['a','b']);
and it gives me an error message:
ERROR: function jsonb_extract_path_text(jsonb, text[]) does not exist
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
What's wrong with these statements? My Postgres version is 9.6.
Upvotes: 2
Views: 6065
Reputation: 125444
SELECT jsonb_extract_path_text('{"a": {"b":{"c": "foo"}}}'::jsonb , 'a','b');
Upvotes: 4