I'm trying to get the Json value from the lat and lon, however keep getting NULL as a result.
What is the right way to get the Lat and Lon values?
DECLARE @JsonValue VARCHAR(MAX) = '{ "CoordSets": [ [ { "Lon": "4.6219456", "Lat": "51.9642514" } ] ] }';
SELECT
JSON_QUERY(@JsonValue, '$.CoordSets[0]'),--returns a value, but all
JSON_VALUE(@JsonValue, '$.CoordSets[0]'),--returns null
JSON_QUERY(@JsonValue, '$.CoordSets[0].Lat'),--returns null
JSON_VALUE(@JsonValue, '$.CoordSets[0].Lat');--returns null
You have a nested array.
SELECT JSON_VALUE(@JsonValue, '$.CoordSets[0][0].Lat');--returns 51.9642514
Are the double square brackets intentional?
September 28, 2020 at 1:38 pm
Thanks a lot! That indeed did the job!
Not sure, getting this results from a supplier, which I think get this data from MapQuest.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy