我在postgres数据库中存储了一个json数组.json看起来像这样:
[
{
"operation": "U",
"taxCode": "1000",
"description": "iva description",
"tax": "12"
},
{
"operation": "U",
"taxCode": "1001",
"description": "iva description",
"tax": "12"
},
{
"operation": "U",
"taxCode": "1002",
"description": "iva description",
"tax": "12"
}
]
Run Code Online (Sandbox Code Playgroud)
现在我需要SELECT数组,以便任何元素都在查询结果的不同行中.所以我执行的SELECT语句必须以这种方式返回数据:
data
--------------------------------------------------------------------------------------
{ "operation": "U", "taxCode": "1000", "description": "iva description", "tax":"12"}
{ "operation": "U", "taxCode": "1001", "description": "iva description", "tax":"12"}
{ "operation": "U", "taxCode": "1002", "description": "iva description", "tax":"12"}
Run Code Online (Sandbox Code Playgroud)
我尝试过使用这个unnest()功能
SELECT unnest(json_data::json)
FROM my_table
Run Code Online (Sandbox Code Playgroud)
但它不接受这种jsonb类型