4

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?

Here's my JSON String:

{"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?

Silvia H
  • 8,097
  • 7
  • 30
  • 33
  • Almost dup of [Parse JSON in TSQL](http://stackoverflow.com/q/2867501/1178314), which asks with a parameter as a source instead of a column, but have good answers and now mention the native JSON support in SQL Server 2016. – Frédéric Feb 26 '16 at 12:40

3 Answers3

8

Since sql server has no JSON support built in, you'd need to parse this manually, which would get complicated.

However, you could always use somebody else's JSON parsing library.

Sam Peacey
  • 5,964
  • 1
  • 25
  • 27
2

For parsing JSON you can write an easy CLR Function in C# or VB.NET.

András Ottó
  • 7,605
  • 1
  • 28
  • 38
2

Now you can use MS SQL Server 2016

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

Beth Lang
  • 1,889
  • 17
  • 38