JSON_ARRAYAGG() is one of the new features introduced in SQL Server 2025. This is an aggregation function that allows you to combine multiple row values into a single JSON array directly within your SQL queries.
JSON_ARRAYAGG() simplifies the process of generating structured JSON output from relational data, which makes it easier to build APIs, export data, and integrate with modern applications that rely on JSON. Instead of manually constructing JSON with string operations or complex subqueries, JSON_ARRAYAGG() provides a clean, efficient way to transform sets of rows into well-formed JSON arrays as part of standard SQL aggregation.