SQLTeam.com | Weblogs | Forums

Parse Elements of Json String Array

Hello
I'm trying to figure out how to extrat element of jstring son array saved in a table colums
The column heve the Name jsonTypes
And below an examples of values

How can I extract for Array[0], Array[1], Array[2] from each row ?

jsonTypes
["WT"]
["WT","OPJ"]
["HYD","MK"]
["WT","HYD","MK"]
["OPJ"]

Thanks a lot for any help

Hello

Unless the json string got manged when posting what you posted is not proper json though column name says jsonTypes

STRING_SPLIT (Transact-SQL) - SQL Server | Microsoft Learn

Thank you Finaly I found the way to rereieve all elements and my Json is properly formated
Considering that there is a max of 4 element in each array

SELECT
JSON_VALUE(jsonTypes, '$[0]') AS FE1
,JSON_VALUE(jsonTypes, '$[1]') AS FE2
,JSON_VALUE(jsonTypes, '$[2]') AS FE3
,JSON_VALUE(jsonTypes, '$[3]') AS FE4
FROM MyTable