簡體   English   中英

如何使用sqlite json-extract提取嵌套的json

[英]how to extract nested json using sqlite json-extract

如何使用 sqlite json-extract 或其他 sqlite json 命令提取嵌套的 json?

在這里我想提取given_id

"invoices": [{

........


    "items": [{


    "given_id": "TBC0003B",


    ...


        }


    ]

   }

]

謝謝。

在 SQLite 中,您可以使用json_extract()如下:

select json_extract(my_json_col, '$.invoices[0].items[0].given_id') my_given_id from mytable

這使您given_id中的第一個元素的屬性items數組的第一個元素下invoices陣列。

DB Fiddle 上的演示

with mytable as (select '{
    "invoices": [{
        "items": [{ "given_id": "TBC0003B" }] 
    }]
}' my_json_col)
select json_extract(my_json_col, '$.invoices[0].items[0].given_id') my_given_id from mytable
| my_given_id |
| :---------- |
| TBC0003B    |

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM