有一個json欄位
[
{'id':'1', 'name':'test1', 'address':'123 Main St'},
{'id':'1', 'name':'test2', 'address':'1404 Burke St'}
]
這就是記錄到達的方式,我想決議 json 并添加額外的列順序,這將告訴它是第一條記錄還是第二條記錄
到目前為止,我有:
select to_variant(parse_json(column)):id, to_variant(to_json(column)):name, to_variant(to_json(column)):address from the table
但無法添加訂單列
uj5u.com熱心網友回復:
你可以試試這樣的東西嗎?
select json.index 1 record_no, json.value:id id, json.value:name name , json.value:address address from
(
select parse_json($$ [ {'id':'1', 'name':'test1', 'address':'123 Main St'},
{'id':'1', 'name':'test2', 'address':'1404 Burke St'} ] $$) c1
),
lateral flatten( parse_json(c1 )) json;
----------- ----- --------- -----------------
| RECORD_NO | ID | NAME | ADDRESS |
----------- ----- --------- -----------------
| 1 | "1" | "test1" | "123 Main St" |
| 2 | "1" | "test2" | "1404 Burke St" |
----------- ----- --------- -----------------
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/470172.html
