Given the following JSON stored in a nvarchar(max)
column, how to generate the table shown? I can make is for if the nested object is an []
, an array, but not a structure {}
DECLARE @JSON AS NVARCHAR(MAX);
SET @JSON = N'{
"ACCOUNT": 1
, "USERS" : {
"BOB" : 1
, "JOHN" : 2
, "RODGER" : 3
}
}';
SELECT JSON_QUERY(@JSON,'$.USERS')
ACCOUNT USER USER_VALUE
================================
1 BOB 1
1 JOHN 2
1 RODGER 3