简体   繁体   English

在sql中解析JSON字符串

[英]Parse JSON string in sql

I have a column of JSON strings in my table, I'm using SQL Server 2008. Any Ideas on how to parse the JSON string and extract a specific value? 我的表中有一列JSON字符串,我正在使用SQL Server 2008.有关如何解析JSON字符串并提取特定值的任何想法?

Here's my JSON String: 这是我的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}]}

I need to extract the value of "name", Any Help? 我需要提取“名称”的值,任何帮助?

Since sql server has no JSON support built in, you'd need to parse this manually, which would get complicated. 由于sql server没有内置的JSON支持,你需要手动解析它,这会变得复杂。

However, you could always use somebody else's JSON parsing library . 但是,您总是可以使用其他人的JSON解析库

要解析JSON,您可以在C#或VB.NET中编写一个简单的CLR函数

Now you can use MS SQL Server 2016 现在您可以使用MS SQL Server 2016

https://msdn.microsoft.com/en-us/library/dn921897.aspx https://msdn.microsoft.com/en-us/library/dn921897.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM