Reputation: 55
I hoping some expert on here will find this easy but I can't seem to get the json values to extract correctly from the below
DECLARE @json NVARCHAR(MAX);
SET @json = '{"test":[{"sId":428659635,"uid":"1110093","rTime":"20180509 05:01:46"}]}';
SELECT JSON_VALUE(@json,'$.test.sId');
I just seems to get Null, is there something I'm missing cause looking on the net its the same as all the examples I've done
Upvotes: 1
Views: 253
Reputation: 13641
test
is an array so you need to index into it.
This should work.
SELECT JSON_VALUE(@json,'$.test[0].sId');
Upvotes: 3