Turns the output of a SELECT into JSON text. In PATH mode the column aliases decide the shape; in AUTO mode the structure of the tables does.
Read more: Microsoft Learn
In the Ultra Transcenders books
Each book explains FOR JSON in context, with comparison tables and the common traps.
Terms in this definition
- SELECT
A DML command in SQL used to retrieve rows from one table or several.
- JSON
Text-based format for structured data. ARM templates and Cosmos DB documents are written in it, and most Azure REST APIs exchange request and response bodies as application/json.
- PATH
Parent-child hierarchies in DAX rely on this function. For each row it builds one delimited text value listing the IDs of the row's ancestors, top level first and ending with the row's own ID, which PATHITEM, PATHLENGTH and friends can then pick apart.
Related terms
- Ingestion mapping
Instructions telling a KQL ingestion which source field goes into which table column, such as by position for CSV files or by JSON path for JSON. You can supply it with the ingestion command or create it on the table beforehand and refer to it by name.
- Modify method
Edits a value in place in a column of the native json type, using syntax such as SET col.modify('\$.path', value). For json columns Microsoft prefers it to JSON_MODIFY.