How to parse json value of text column in postgres
11,888
You could use the ->
operator:
SELECT '{"summary":"this is a example","url":"stackoverflow.com"}'::json->'url';
Author by
or123456
Updated on June 19, 2022Comments
-
or123456 almost 2 years
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.
-
mwKART over 2 yearswhat if i have a json value like, {"summary":"this is a example","uri" : [{"url":"stackoverflow.com"}]}, how to get url
-
lgx about 2 yearsnote that it will display
"stackoverflow.com"
instead ofstackoverflow.com
. So it includes quotation marks