繁体   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