Ask Your Question
2

After upgrading org.postgresql, why are double quotes appearing in the result of the select statement for JSONB type?

asked 2023-06-10 20:11:19 +0000

scrum gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-06-10 20:40:02 +0000

pufferfish gravatar image

This could be due to changes in the handling of special characters or the way the new version of PostgreSQL escapes certain characters in JSONB data. It is recommended to check the documentation of the new version for any changes in this regard and adjust the query accordingly.

One way to remove the double quotes in the result of the select statement for JSONB type is to use the ->> operator instead of the -> operator. For example,

SELECT column_name->>'key_name' FROM table_name;

This will return the value of the key without the double quotes. Alternatively, you can use the jsonb_build_object function to build the JSON object and return the string representation without the double quotes. For example,

SELECT jsonb_build_object('key_name', column_name->>'key_name')::text FROM table_name;

This will return the value of the key as a string without the double quotes.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-06-10 20:11:19 +0000

Seen: 12 times

Last updated: Jun 10 '23