2

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.

1 Answer 1

4
SELECT jsonb_extract_path_text('{"a": {"b":{"c": "foo"}}}'::jsonb , 'a','b');
Sign up to request clarification or add additional context in comments.

1 Comment

1) it's json array inside 2) I need like query. Will it work?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.