简体   繁体   中英

How to parse json value of text column in postgres

I have a column of text type be contain json value.

{"summary":"this is a example","url":"stackoverflow.com"}

How can I extract ' url ' json field of column in postgres with query?

I used of following query:

 SELECT jvalue->>'url' From table;

With my query, I get following error.

SQL Error [42883]: ERROR: operator does not exist: text ->> unknown Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts. org.postgresql.util.PSQLException: ERROR: operator does not exist: text ->> unknown Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.

您可以使用->运算符:

SELECT '{"summary":"this is a example","url":"stackoverflow.com"}'::json->'url';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM