I am using PGADMIN4 to extract data elements from JSONB field called "resource" (postgress database). Here is the example of JSONB:
"resource": {
"type": [
{
"text": "assessment",
"coding": [
{
"code": "000000000",
"system": " ",
"display": "assessment"
},
{
"code": "111111111",
"system": " ",
"display": "test"
}
]
}
]
I used the following code to extract text, code and display. I am able to extract the text correctly by code and display are null. Can someone please help.
select jsonb_array_elements(a.resource -> 'resource' -> 'type') ->> 'text' as encounter_text,
jsonb_array_elements(a.resource -> 'resource' -> 'type' -> 'coding') ->> 'code' as code,
jsonb_array_elements(a.resource -> 'resource' -> 'type' -> 'coding') ->> 'display' as display
from data a
question from:
https://stackoverflow.com/questions/65854580/not-able-to-extract-data-element-from-the-jsonb-field 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…