I have a table called flow_flowrun and an array of json objects under a column called EVENTS like so:
[{"msg": {"urn": "tel:+1238948372", "text": "Would you like to JOIN, reply now", "uuid": "34567a-a634-4c1d-a0a5-56788", "channel": {"name": "*56789", "uuid": "b5bc6e6c-ad18-493f-b28f-744627e739f7"}}, "type": "msg_created", "step_uuid": "a4fg6hh-9419-43a4-tgdv-39a4edc78d69", "created_on": "2015-09-21T06:10:12.217880+00:00"}]
[{"msg": {"urn": "tel:+1294472830", "text": "Hello, how do you feel today", "uuid": "533457-693d-4d67-833c-0d53e7e0ff98", "channel": {"name": "*12345", "uuid": "b5bc6e6c-ad18-493f-b28f-744627e739f7"}}, "type": "msg_created", "step_uuid": "4556763-1f5b-40a4-a29d-5fb1103f4666", "created_on": "2014-02-08T06:04:57.823739+00:00"}]
I'd like to run a query that shows just the 'text' output. So the output should look like this:
Messages Would you like to JOIN, reply now Hello, how do you feel today
and so on...
I've tried the following with no luck:
SELECT jsonb_array_elements(fr.events->'msg'->'text') elem
FROM flows_flowrun fr
SELECT fr.EVENTS ->>'text'
from flows_flowrun fr
Thanks in anticipation.
When I run the above queries I get no results.
You'll need to expand the array first and access members over that:
SELECT jsonb_array_elements(events)->'msg'->>'text'
FROM flows_flowrun fr
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.