Troubleshooting Guide: SQL Server Error 11564 – Malformed JSON Parameter
Why This Error Happens
Error 11564 occurs when a SQL Server JSON function (such as JSON_OBJECT, JSON_ARRAY, OPENJSON, or the newer native JSON type validation methods in SQL Server 2025) receives a parameter that does not conform to valid JSON syntax. This is typically caused by unescaped special characters, mismatched brackets/braces, trailing commas, or a NULL/empty string being passed where a structured JSON object was expected. It can also occur if an application layer (e.g., a .NET or Python driver) serializes the payload incorrectly before sending it to the server, or if a stored procedure concatenates JSON fragments without validating the final string.
Step-by-Step Resolution Guide
Step 1: Isolate the Offending Parameter
- Capture the exact query via SQL Server Profiler or Extended Events (
sqlserver.error_reportedfiltered on Error = 11564). - Extract the literal JSON string value being passed into the parameter at the time of failure.
- Run
SELECT ISJSON('your_captured_string_here');in SSMS to confirm if it returns0(invalid).
Step 2: Validate and Correct the JSON Syntax
- Check for common formatting errors: trailing commas, single quotes instead of double quotes for keys/values, or unescaped backslashes.
- If the JSON is dynamically built in T-SQL, use
STRING_ESCAPE(value, 'json')to properly escape special characters before concatenation. - For application-side issues (Windows 11 client apps), verify the serialization library (e.g.,
System.Text.JsonorNewtonsoft.Json) is configured to output strict JSON compliant with RFC 8259.
Step 3: Update Connection and Driver Configuration
- On Windows Server 2025, ensure the ODBC Driver or OLE DB Provider is updated to the latest version supporting SQL Server 2025’s native JSON data type (introduced in this release).
- Navigate to
Control Panel > Administrative Tools > ODBC Data Sources (64-bit)and verify the driver version under the “Drivers” tab is “ODBC Driver 18 for SQL Server” or later. - If using a legacy driver, update the connection string to disable automatic type coercion that might be mangling the JSON payload mid-transit.
Step 4: Test with a Sanitized Payload
- Manually reconstruct the query in SSMS using a known-good, minimal JSON object (e.g.,
{"key":"value"}). - Execute the query to confirm the procedure or function itself is not the root cause.
- Gradually reintroduce the original data fields to pinpoint which specific key-value pair is breaking the parser.
Alternative or Verification Steps
- Verification: Re-run the original transaction or API call that triggered the error; confirm Error 11564 no longer appears in the SQL Server Error Log (
Management > SQL Server Logsin SSMS). - Alternative: If the data source is unreliable (e.g., third-party API), wrap the JSON parameter in a
TRY_CONVERT(NVARCHAR(MAX), @param)combined with anISJSON()check within your stored procedure to gracefully handle malformed input before it hits the native JSON parser.