Say I have a JSON data stored in a varchar(max)
column in a database. Is it possible to use SQL to get all the JSON paths present in that data. For example for the following JSON:
{
"dog":
{
"name":"Rover",
"age": 6,
"likes:["catch", "eating"]
}
}
I would get the output of:
$.
$.dog
$.dog.name
$.dog.age
$.dog.likes[0]
$.dog.likes[1]
I have looked at functions including json_query
and json_value
but they seem to be more about getting data from the JSON rather than the metadata I require.
I am using SQL Server 2018.