# JSON data type In SQL (Azure SQL Database and SQL Server 2025+), the `JSON` datatype stores structured JSON values as binary but is treated as a string for input. > [!IMPORTANT] > We will treat JSON as a `string` both as input and output. ```sql CREATE TABLE profiles ( id INT PRIMARY KEY, metadata JSON ) ``` ## Reading JSON With `FOR JSON`, SQL emits JSON columns as objects. ```sql SELECT id, metadata FROM profiles FOR JSON AUTO; ``` ```json [ { "id": 1, "metadata": { "role": "admin", "preferences": { "darkMode": true } } } ] ``` Data API builder (DAB) will return JSON columns as raw strings: ```json { "value": [ { "id": 1, "metadata": "{\"role\":\"admin\",\"preferences\":{\"darkMode\":true}}" } ] } ``` ## Writing JSON JSON values must be passed as valid strings. ```sql INSERT INTO profiles (id, metadata) VALUES ( 2, '{"role":"guest","preferences":{"darkMode":false}}' ); ``` DAB input example: ```http POST /profiles Content-Type: application/json { "id": 2, "metadata": "{\"role\":\"guest\",\"preferences\":{\"darkMode\":false}}" } ``` ## Notes 1. SQL validates JSON syntax, not DAB. 2. Neither SQL nor DAB enforces a schema.
Activity
[-][Enhancement]: Support JSON data type for MSSQL[/-][+][Enh]: Support JSON data type for MSSQL[/+][-][Enh]: Support JSON data type for MSSQL[/-][+][Enh]: Support `JSON` data type for MSSQL[/+]25 remaining items
[Phase 2] Enable MSSQL JSON data type - type mapping & error codes (e…
[Phase 3] MSSQL JSON - test fixture + REST CRUD tests (#3720)
fix(mssql-json): return native json as string in read path + address …
[Phase 3b] MSSQL JSON - return json as string on read + OpenAPI/Graph…
[Phase 4] MSSQL JSON - malformed-JSON (400) + filter edge-case tests (#…