在SQL中解析JSON字符串

4

我有一列JSON字符串在我的表中,我正在使用SQL Server 2008。
你有什么想法可以解析JSON字符串并提取特定的值吗?

这是我的JSON字符串:

{"id":1234,"name":"Lasagne al frono","description":"Placerat nisi turpis, dictumst nasceture ete etiam mus nec cum platea tempori zillest. Nisi niglue, augue adipiscing ete dignissim sed mauris augue, eros!","image":"images/EmptyProduct.jpg","cartImage":"images/ArabianCoffee.jpg","basePrice":54.99,"priceAttribute":"itemPrice","attributes":[{"type":"Addons","label":"Side","attributeName":"Side","display":"Small","lookupId":8},{"type":"Addons","label":"Drink","attributeName":"drink","display":"Small","lookupId":5},{"label":"add note","type":"Text","attributeName":"notes","display":"Wide","lookupId":null}]}

我需要提取“name”的值,有什么帮助吗?

这几乎是 在 TSQL 中解析 JSON 的副本,它使用参数作为源而不是列,但有很好的答案,并且现在提到了 SQL Server 2016 中的本机 JSON 支持。 - Frédéric
3个回答

8

由于SQL Server没有内置的JSON支持,您需要手动解析,这会变得很复杂。

但是,您可以使用其他人的JSON解析库


2

要解析JSON数据,您可以使用C#或VB.NET编写简单的CLR函数


2

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接