gpt4 book ai didi

sql-server - 在 SQL 中解析 JSON

转载 作者:IT老高 更新时间:2023-10-28 12:42:09 24 4
gpt4 key购买 nike

是否可以在TSQL中解析JSON

我不是要创建 JSON 字符串;相反,我想解析作为 parameter 传入的 JSON 字符串。

最佳答案

我似乎有一个巨大的自虐倾向,因为我编写了一个 JSON 解析器。它将 JSON 文档转换为 SQL 邻接表,便于使用它来更新您的数据表。实际上,我做得更糟,因为我编写了代码来执行相反的过程,即从层次结构表转到 JSON 字符串

文章和代码在这里:Consuming Json strings in SQL server

Select * from parseJSON('{
"Person":
{
"firstName": "John",
"lastName": "Smith",
"age": 25,
"Address":
{
"streetAddress":"21 2nd Street",
"city":"New York",
"state":"NY",
"postalCode":"10021"
},
"PhoneNumbers":
{
"home":"212 555-1234",
"fax":"646 555-4567"
}
}
}
')

To get:

enter image description here

关于sql-server - 在 SQL 中解析 JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2867501/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com