我想查询这个json示例并选择 questions.title 和 questions.answers[ ].references[ ].id (用“,”连接的字符串很好)。
到目前为止,我使用 json_table 得到了以下结果,但参考 id 没有成功:
select key_v, title, refs
from ASSESSMENT a,
json_table (ASSESSMENT , '$'
columns (key_v FOR ORDINALITY,
nested path '$."questions".*'
columns (
title path '$."title"',
refs path '$.answers[*].references."eocnurse:interventions"[*].id',
)));
基于示例的期望结果
“Cambiamento dello stato cognitivo” - “247, 77253”
“Stato della circolazione” - “81, 24853608585”
“Sonno e riposo” - “24853608585”
Oracle 版本:Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
UDPATE
我设法修改了json数据结构以符合JSONpath。
使用更新的 json 结构,这是我的问题的解决方案:
select JT.*
from ASSESSMENT a,
json_table (ASSESSMENT , '$.questions[*]'
columns (
"Title" PATH '$.title',
"Refs" VARCHAR2(500 CHAR) FORMAT JSON WITH WRAPPER PATH '$.answers[*].references."eocnurse:interventions"[*].id'
))
"JT";