JSON path in SQL Server
As you saw from the list of new functions in SQL Server 2022, there is a specific function related to the JSON path. So, what is the JSON path? In essence, the JSON path involves mapping the key-value pairs and arrays through a known construction that is commonly used in JSON and implemented in SQL Server. Because a JSON document can be nested indefinitely and inconsistently, it is important to understand how to refer to various objects and arrays within the document that you are working with.
In SQL Server, the following format is commonly used to interrogate a JSON document. It starts with a root and then uses curly braces and dots to fully describe the path:
'$.Restaurant.Name'
The dollar sign ($
) represents the context or starting point for the path. Depending on how you’re interfacing with the JSON document, this could be a field in a table or a parameter being sent into your stored procedure, for example. It is effectively the...