{
"explosives_UG":{
"isCritical": false,
"value": "N/A"
},
"explosivesUG": {
"comment": "Test 619 313",
"createWo": false,
"isCritical": false,
"value": "No"
},
"generalAttachment": null,
"generalComment": "Test 619 313",
"guardsPostedUG": {
"isCritical": false,
"value": "Yes"
},
"imminentUG": {
"isCritical": false,
"value": "Yes"
}
}
using the above JSON format, output is generated as below via Snowflake query
question answer
explosives_UG N/A
explosivesUG No
guardsPostedUG Yes
imminentUG Yes
SELECT
kv.key AS question,
kv.value:value AS answer
FROM
json_data,
LATERAL FLATTEN(input => json_col) kv
WHERE
kv.key IN ('explosives_UG', 'explosivesUG', 'guardsPostedUG', 'imminentUG');
Question : We will be getting lot of questions/answers and handling them manually in the code is time consuming..
How to use dynamically extract JSON values using LATERAL FLATTEN, can somebody help please…