[英]how to extract nested json using sqlite json-extract
How could I extract nested json using sqlite json-extract or other sqlite json command ?如何使用 sqlite json-extract 或其他 sqlite json 命令提取嵌套的 json?
Here I'd like to extract given_id在这里我想提取given_id
"invoices": [{
........
"items": [{
"given_id": "TBC0003B",
...
}
]
}
]
Thanks.谢谢。
In SQLite you can use json_extract()
as follows:在 SQLite 中,您可以使用json_extract()
如下:
select json_extract(my_json_col, '$.invoices[0].items[0].given_id') my_given_id from mytable
This gives you the given_id
attribute of the first element of the items
array under first element of the invoices
array.这使您given_id
中的第一个元素的属性items
数组的第一个元素下invoices
阵列。
Demo on DB Fiddle : 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.