I am trying to extract the key and value pair from a nested JSON in an Oracle database. The JSON is saved as a CLOB in my database.
I am unsuccessful in getting the key name from my query:
select key_v, var_name, sub_q
from sampletable,
json_table (sample_json , '$'
columns (key_v varchar2(36) path '$."result"."exportColumnMap"',
nested path '$."result"."exportColumnMap".*'
columns (var_name varchar2(24) path '$."question"',
sub_q varchar2(36) path '$."choice"'
)))
where var_name is not null;
Ideally the resulting table from the select statement ends up as
KEY_1, ANSWER1, QUESTION1
KEY_2, ANSWER2, QUESTION2
KEY_3, ANSWER3, QUESTION3
sample_json:
{"result":
"exportColumnMap": {
"KEY_1": {
"choice": "ANSWER1",
"question": "QUESTION1"
},
"KEY_2": {
"choice": "ANSWER2",
"question": "QUESTION2"
},
"KEY_3": {
"choice": "ANSWER3",
"question": "QUESTION3"
}}}